天天看點

Android 5.x浏覽器webView或者qqX5崩潰,Resources$NotFoundException:String resource ID #0x2040003

Android 5.x浏覽器webView或者qqX5崩潰,Resources$NotFoundException:String resource ID #0x2040003

周末客戶回報app中h5頁面崩潰,bugly顯示

java.lang.RuntimeException:Unable to start activity ComponentInfo{com.gw.huiyou/com.stategrid.ghwapp.module.main.views.GoodsWebActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class net.coming.dev.view.MyX5WebView
2 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
3 ......
4 Caused by:
5 android.content.res.Resources$NotFoundException:String resource ID #0x2040003
6 android.content.res.Resources.getText(Resources.java:338)
7 android.content.res.VivoResources.getText(VivoResources.java:123)
8 android.content.res.Resources.getString(Resources.java:436)
9 com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:694)
10 com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:618)
11 com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:674)
12 com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:823)
13 com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:662)
14 com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:597)
15 com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:319)
16 com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:104)
17 com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:271)
18 com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:131)
19 com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:118)
20 com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
21 com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:115)
22 com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:268)
23 android.webkit.WebView.<init>(WebView.java:591)
24 android.webkit.WebView.<init>(WebView.java:526)
25 android.webkit.WebView.<init>(WebView.java:509)
26 android.webkit.WebView.<init>(WebView.java:496)
27 com.tencent.smtt.sdk.WebView$a.<init>(Unknown Source)
28 com.tencent.smtt.sdk.WebView.<init>(Unknown Source)
29 com.tencent.smtt.sdk.WebView.<init>(Unknown Source)
30 com.tencent.smtt.sdk.WebView.<init>(Unknown Source)
31 com.tencent.smtt.sdk.WebView.<init>(Unknown Source)
32 net.coming.dev.view.MyX5WebView.<init>(MyX5WebView.java:88)
33 java.lang.reflect.Constructor.newInstance(Native Method)
34 java.lang.reflect.Constructor.newInstance(Constructor.java:288)
35 android.view.LayoutInflater.createView(LayoutInflater.java:607)
36 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
37 android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
38 android.view.LayoutInflater.inflate(LayoutInflater.java:504)
39 android.view.LayoutInflater.inflate(LayoutInflater.java:414)
40 android.view.LayoutInflater.inflate(LayoutInflater.java:365)
41 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
42 androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
43 net.coming.dev.ioc.IocBaseActivity.setContentView(IocBaseActivity.java:44)
44 com.stategrid.ghwapp.module.main.views.GoodsWebActivity.initView(GoodsWebActivity.java:107)
45 net.coming.dev.base.BaseMvpActivity.onCreate(BaseMvpActivity.java:72)
46 android.app.Activity.performCreate(Activity.java:6176)
47 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1115)
48 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2532)
49 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2659)
50 android.app.ActivityThread.access$900(ActivityThread.java:188)
51 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
52 android.os.Handler.dispatchMessage(Handler.java:111)
53 android.os.Looper.loop(Looper.java:194)
54 android.app.ActivityThread.main(ActivityThread.java:5714)
55 java.lang.reflect.Method.invoke(Native Method)
56 java.lang.reflect.Method.invoke(Method.java:372)
57 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:984)
58 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
           

看到問題貌似不是代碼中的,考慮是不是qq x5的問題,換了原生webView依然不見效。百度一圈,雖然找到類似問題,可是并沒有解決方案。最後決定用笨方法,代碼復原。根據不同時段webview在Android5.x中的運作情況,定位到遷移androidx後,更新1.1.0出現了問題:

appcompat              : 'androidx.appcompat:appcompat:1.1.0',
           

當引用1.0.0時正常,原來這一版對webview有更改。為了快速修複問題,先行後退版本。