Error inflating class android.webkit.WebView NotFoundException: String resource ID #0x2040002

在Android 5.0.1手机上出现WebView加载出错问题,具体报错信息:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lianzhuoxinxi.baoduoduo/com.lianzhuoxinxi.baoduoduo.ui.other.WebViewActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class android.webkit.WebView
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2426)
	at android.app.ActivityThread.access$900(ActivityThread.java:155)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5318)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class android.webkit.WebView
	at android.view.LayoutInflater.createView(LayoutInflater.java:633)
	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
	at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(SourceFile:9)
	at androidx.appcompat.app.AppCompatActivity.setContentView(SourceFile:1)
	at com.lianzhuoxinxi.baoduoduo.base.BaseActivity.onCreate(SourceFile:2)
	at android.app.Activity.performCreate(Activity.java:6024)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
	... 10 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
	at android.view.LayoutInflater.createView(LayoutInflater.java:607)
	... 23 more
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002
	at android.content.res.Resources.getText(Resources.java:296)
	at android.content.res.VivoResources.getText(VivoResources.java:123)
	at android.content.res.Resources.getString(Resources.java:382)
	at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:741)
	at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:647)
	at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
	at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
	at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
	at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
	at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
	at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
	at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:261)
	at android.webkit.WebView.<init>(WebView.java:548)
	at android.webkit.WebView.<init>(WebView.java:483)
	at android.webkit.WebView.<init>(WebView.java:466)
	at android.webkit.WebView.<init>(WebView.java:453)
	... 26 more
android.view.InflateException: Binary XML file line #13: Error inflating class android.webkit.WebView
	at android.view.LayoutInflater.createView(LayoutInflater.java:633)
	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
	at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(SourceFile:9)
	at androidx.appcompat.app.AppCompatActivity.setContentView(SourceFile:1)
	at com.lianzhuoxinxi.baoduoduo.base.BaseActivity.onCreate(SourceFile:2)
	at android.app.Activity.performCreate(Activity.java:6024)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2426)
	at android.app.ActivityThread.access$900(ActivityThread.java:155)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5318)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
	at android.view.LayoutInflater.createView(LayoutInflater.java:607)
	... 23 more
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002
	at android.content.res.Resources.getText(Resources.java:296)
	at android.content.res.VivoResources.getText(VivoResources.java:123)
	at android.content.res.Resources.getString(Resources.java:382)
	at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:741)
	at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:647)
	at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
	at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
	at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
	at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
	at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
	at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
	at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:261)
	at android.webkit.WebView.<init>(WebView.java:548)
	at android.webkit.WebView.<init>(WebView.java:483)
	at android.webkit.WebView.<init>(WebView.java:466)
	at android.webkit.WebView.<init>(WebView.java:453)
	... 26 more
java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
	at android.view.LayoutInflater.createView(LayoutInflater.java:607)
	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
	at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(SourceFile:9)
	at androidx.appcompat.app.AppCompatActivity.setContentView(SourceFile:1)
	at com.lianzhuoxinxi.baoduoduo.base.BaseActivity.onCreate(SourceFile:2)
	at android.app.Activity.performCreate(Activity.java:6024)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2426)
	at android.app.ActivityThread.access$900(ActivityThread.java:155)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5318)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002
	at android.content.res.Resources.getText(Resources.java:296)
	at android.content.res.VivoResources.getText(VivoResources.java:123)
	at android.content.res.Resources.getString(Resources.java:382)
	at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:741)
	at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:647)
	at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
	at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
	at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
	at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
	at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
	at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
	at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:261)
	at android.webkit.WebView.<init>(WebView.java:548)
	at android.webkit.WebView.<init>(WebView.java:483)
	at android.webkit.WebView.<init>(WebView.java:466)
	at android.webkit.WebView.<init>(WebView.java:453)
	... 26 more
android.content.res.Resources$NotFoundException: String resource ID #0x2040002
	at android.content.res.Resources.getText(Resources.java:296)
	at android.content.res.VivoResources.getText(VivoResources.java:123)
	at android.content.res.Resources.getString(Resources.java:382)
	at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:741)
	at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:647)
	at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
	at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
	at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
	at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
	at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
	at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
	at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
	at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
	at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:261)
	at android.webkit.WebView.<init>(WebView.java:548)
	at android.webkit.WebView.<init>(WebView.java:483)
	at android.webkit.WebView.<init>(WebView.java:466)
	at android.webkit.WebView.<init>(WebView.java:453)
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
	at android.view.LayoutInflater.createView(LayoutInflater.java:607)
	at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
	at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
	at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(SourceFile:9)
	at androidx.appcompat.app.AppCompatActivity.setContentView(SourceFile:1)
	at com.lianzhuoxinxi.baoduoduo.base.BaseActivity.onCreate(SourceFile:2)
	at android.app.Activity.performCreate(Activity.java:6024)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2426)
	at android.app.ActivityThread.access$900(ActivityThread.java:155)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5318)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)

由于我们项目转成了androidX,在依赖库中导入了:

implementation 'androidx.appcompat:appcompat:1.1.0'

在stackoverflow有人给出解决方案:
stackoverflow

发布了30 篇原创文章 · 获赞 16 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/chenyingjie_Android/article/details/104170005