Android Webview - 当你 getPackageName it Fatal 时

Android Webview - when you I the getPackageName it Fatal

提问人:Jack Fan 提问时间:1/14/2022 更新时间:1/14/2022 访问量:233

问:

@Override
public String getPackageName() {
    if(!TextUtils.isEmpty(Bridge.sFakePkgnameCallstack)){
        StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
        for (int i = 0; i < stackTraceElements.length; i++) {
            String clsname = stackTraceElements[i].getClassName();
            if(clsname.matches(Bridge.sFakePkgnameCallstack)) {
                Log.d("Application", "getPackageName:" + Bridge.sFakePkgname + " stack:" + stackTraceElements[i].toString());
                return Bridge.sFakePkgname;
            }
        }
    }
    return super.getPackageName();
}

该问题是间歇性的,仅在某些设备上发生。例如,我们的测试设备:Samsung SM - A520F Android 8 (SDK 26) - Webview Chrome 90.0.4430.82

该问题发生在我们 2022 年 1 月发布的应用程序版本中。

11-12 18:15:31.595 30171 30171 D Application: getPackageName:ilx.mTAR.mplJt stack:android.webkit.WebView.<init>(WebView.java:651)
11-12 18:15:31.597 30171 30171 W System.err: java.lang.ExceptionInInitializerError
11-12 18:15:31.597 30171 30171 W System.err:    at org.chromium.base.BuildInfo.getAll(PG:1)
11-12 18:15:31.597 30171 30171 W System.err:    at org.chromium.content.browser.BrowserStartupControllerImpl.nativeSetCommandLineFlags(Native Method)
11-12 18:15:31.597 30171 30171 W System.err:    at Ti2.run(PG:5)
11-12 18:15:31.597 30171 30171 W System.err:    at org.chromium.content.browser.BrowserStartupControllerImpl.a(PG:38)
11-12 18:15:31.597 30171 30171 W System.err:    at org.chromium.content.browser.BrowserStartupControllerImpl.b(PG:7)
11-12 18:15:31.597 30171 30171 W System.err:    at org.chromium.android_webview.AwBrowserProcess.a(PG:29)
11-12 18:15:31.597 30171 30171 W System.err:    at dC0.run(Unknown Source:2)
11-12 18:15:31.597 30171 30171 W System.err:    at org.chromium.base.ThreadUtils.c(PG:2)
11-12 18:15:31.597 30171 30171 W System.err:    at in.m(PG:34)
11-12 18:15:31.597 30171 30171 W System.err:    at in.a(PG:48)
11-12 18:15:31.597 30171 30171 W System.err:    at in.b(PG:16)
11-12 18:15:31.597 30171 30171 W System.err:    at com.android.webview.chromium.WebViewChromiumFactoryProvider.a(PG:32)
11-12 18:15:31.597 30171 30171 W System.err:    at com.android.webview.chromium.WebViewChromium.init(PG:12)
11-12 18:15:31.597 30171 30171 W System.err:    at android.webkit.WebView.<init>(WebView.java:651)
11-12 18:15:31.597 30171 30171 W System.err:    at android.webkit.WebView.<init>(WebView.java:581)
11-12 18:15:31.597 30171 30171 W System.err:    at android.webkit.WebView.<init>(WebView.java:564)
11-12 18:15:31.597 30171 30171 W System.err:    at android.webkit.WebView.<init>(WebView.java:551)
11-12 18:15:31.597 30171 30171 W System.err:    at android.webkit.WebView.<init>(WebView.java:541)
11-12 18:15:31.597 30171 30171 W System.err:    at org.cocos2dx.lib.Cocos2dxWebView.<init>(SourceFile:84)
11-12 18:15:31.597 30171 30171 W System.err:    at org.cocos2dx.lib.Cocos2dxWebViewHelper$1.run(SourceFile:95)
11-12 18:15:31.597 30171 30171 W System.err:    at android.os.Handler.handleCallback(Handler.java:789)
11-12 18:15:31.597 30171 30171 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:98)
11-12 18:15:31.597 30171 30171 W System.err:    at android.os.Looper.loop(Looper.java:164)
11-12 18:15:31.597 30171 30171 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:6944)
11-12 18:15:31.597 30171 30171 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
11-12 18:15:31.597 30171 30171 W System.err:    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
11-12 18:15:31.597 30171 30171 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
11-12 18:15:31.597 30171 30171 W System.err: Caused by: java.lang.RuntimeException: android.content.pm.PackageManager$NameNotFoundException: ilx.mTAR.mplJt
11-12 18:15:31.598 30171 30171 W System.err:    at org.chromium.base.BuildInfo.<init>(PG:31)
11-12 18:15:31.598 30171 30171 W System.err:    at yG0.<clinit>(PG:1)
11-12 18:15:31.598 30171 30171 W System.err:    ... 27 more
11-12 18:15:31.598 30171 30171 W System.err: Caused by: android.content.pm.PackageManager$NameNotFoundException: ilx.mTAR.mplJt
11-12 18:15:31.598 30171 30171 W System.err:    at android.app.ApplicationPackageManager.getPackageInfoAsUser(ApplicationPackageManager.java:298)
11-12 18:15:31.598 30171 30171 W System.err:    at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:269)
11-12 18:15:31.598 30171 30171 W System.err:    at org.chromium.base.BuildInfo.<init>(PG:6)
11-12 18:15:31.598 30171 30171 W System.err:    ... 28 more
11-12 18:15:31.607 30171 30171 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 30171 (O4f.fI3Q.bDYEdH)
Android WebView

评论


答: 暂无答案