qq_43029833 2018-08-22 08:53 采纳率: 0%
浏览 1949
已结题

插件中的 WebView 發生资源 NotFoundException

已经2个星期还是无法解决这个问题,每天被PM追杀,Help me ~~~ Orz...

目前 App 满足下列3个条件将导致 WebView 发生 NotFoundException:
1. Android 7以上
2. chrome 升级到67版本以上
3. app 开启插件前有先使用过 WebView 元件

加载插件资源的方式:

protected void loadResources() throws InstantiationException, IllegalAccessException, 
        IllegalArgumentException,InvocationTargetException, NoSuchMethodException,
        NoSuchFieldException {
    mAssetManager = AssetManager.class.newInstance();

    AssetManager.class.getMethod("addAssetPath", String.class).invoke(mAssetManager, dexPath);
    //AssetManager.class.getMethod("addAssetPath", String.class).invoke(mAssetManager,
        getSourceDir());  

    if (mResources == null) {
        mResources = new Resources(mAssetManager, getResources().getDisplayMetrics(),
            getResources().getConfiguration());
    }       

    mTheme = mResources.newTheme();
    mTheme.applyStyle(android.R.style.Theme_Light_NoTitleBar_Fullscreen, true);
}

参考:
https://www.jianshu.com/p/89e2a4165fb6

尝试:
1.尝试将 WebView 的资源加载进新的 AssetManager,但依旧是 NotFoundException

private String getSourceDir() {
        String webviewImplPackageName = null;
        PackageInfo packageInfo = null;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            webviewImplPackageName = Settings.Global.getString(getApplication().getContentResolver(),
                "webview_provider");
        }

        try {
            packageInfo = getApplication().getPackageManager().getPackageInfo(webviewImplPackageName,
                PackageManager.GET_META_DATA);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return packageInfo.applicationInfo.sourceDir;
}
2.尝试将 sharedLibraryFiles 清空,但依旧是 NotFoundException
private void delet() {
        getApplicationInfo().sharedLibraryFiles = new String[0];       
}

错误Log:
W/ResourceType: No known package when getting value for resource number 0x020b001b
W/System.err: android.content.res.Resources$NotFoundException: Resource ID #0x20b001b
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:209)
at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:91)
at android.content.res.Resources.getInteger(Resources.java:1096)
at org.chromium.ui.base.DeviceFormFactor.b(SourceFile:5)
at org.chromium.ui.base.DeviceFormFactor.isTablet(SourceFile:3)
at org.chromium.android_webview.AwSettings.nativeUpdateEverythingLocked(Native Method)
at org.chromium.android_webview.AwSettings.ac(SourceFile:71)
at org.chromium.android_webview.AwSettings.a(SourceFile:69)
at org.chromium.android_webview.AwContents.e(SourceFile:212)
at org.chromium.android_webview.AwContents.d(SourceFile:153)
at org.chromium.android_webview.AwContents.(SourceFile:81)
at uY.run(SourceFile:15)
at ahv.a(SourceFile:13)
at ahw.run(SourceFile:2)
at org.chromium.base.ThreadUtils.b(SourceFile:31)
at ahv.a(SourceFile:7)
at com.android.webview.chromium.WebViewChromiumFactoryProvider.b(SourceFile:6)
at com.android.webview.chromium.WebViewChromium.init(SourceFile:111)
at android.webkit.WebView.(WebView.java:651)
at android.webkit.WebView.(WebView.java:581)
at android.webkit.WebView.(WebView.java:564)
at android.webkit.WebView.(WebView.java:551)
at android.webkit.WebView.(WebView.java:541)
at candan.sectionapk.MainActivity$1.onClick(MainActivity.java:50)
at android.view.View.performClick(View.java:6266)
at android.view.View$PerformClick.run(View.java:24730)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
A/chromium: [FATAL:jni_android.cc(258)] Please include Java exception stack in crash report
W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
Chrome build fingerprint:
68.0.3440.91
344009152

  • 写回答

3条回答

  • 75闪光雷 2018-08-22 09:30
    关注

    兄弟你报错的位置是.ResourcesImpl.getValue(ResourcesImpl.java:209)
    你贴的代码没有这个方法啊ResourcesImpl.getValue
    建议debug断点调试这路里

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题