WebView 初始化失败

时间:2021-08-28 14:37:11

最近遇到一个奇怪的问题。我在创建一个Webview的时候,给我报空了。

很奇怪,初始化报空,相信很多人都没有遇到过。

而且公司只有那么一个机子出现问题了,其他的都是可以的。我就怀疑是机子问题,可是我去新建一个工程,去初始化WebView的时候,又成功了。这TM就尴尬了,到底是机子问题,还是代码问题呢?

10-24 10:58:06.764 3957-3957/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 PID: 3957
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yunos.tvtaobao/com.yunos.tvtaobao.WebActivity}: java.lang.NullPointerException: java.lang.NullPointerException
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:136)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5031)
                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:515)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:816)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
                                                  Caused by: java.lang.NullPointerException: java.lang.NullPointerException
                                                     at com.android.org.chromium.base.PathUtils.getDataDirectory(PathUtils.java:55)
                                                     at com.android.org.chromium.content.browser.ResourceExtractor.getOutputDirFromContext(ResourceExtractor.java:308)
                                                     at com.android.org.chromium.content.browser.ResourceExtractor.<init>(ResourceExtractor.java:266)
                                                     at com.android.org.chromium.content.browser.ResourceExtractor.get(ResourceExtractor.java:232)
                                                     at com.android.org.chromium.content.browser.AndroidBrowserProcess.init(AndroidBrowserProcess.java:62)
                                                     at com.android.org.chromium.android_webview.AwBrowserProcess$1.run(AwBrowserProcess.java:51)
                                                     at com.android.org.chromium.base.ThreadUtils.runOnUiThreadBlocking(ThreadUtils.java:56)
                                                     at com.android.org.chromium.android_webview.AwBrowserProcess.start(AwBrowserProcess.java:46)
                                                     at com.android.webview.chromium.WebViewChromiumFactoryProvider.startChromiumLocked(WebViewChromiumFactoryProvider.java:184)
                                                     at com.android.webview.chromium.WebViewChromiumFactoryProvider.ensureChromiumStartedLocked(WebViewChromiumFactoryProvider.java:107)
                                                     at com.android.webview.chromium.WebViewChromiumFactoryProvider.startYourEngines(WebViewChromiumFactoryProvider.java:259)
                                                     at com.android.webview.chromium.WebViewChromium.init(WebViewChromium.java:222)
                                                     at android.webkit.WebView.<init>(WebView.java:508)
                                                     at android.webkit.WebView.<init>(WebView.java:475)
                                                     at android.webkit.WebView.<init>(WebView.java:455)
                                                     at android.webkit.WebView.<init>(WebView.java:444)
                                                     at android.webkit.WebView.<init>(WebView.java:434)
                                                     at com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)
                                                     at android.app.Activity.performCreate(Activity.java:5231)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:136) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5031) 
                                                     at java.lang.reflect.Method.invokeNative(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:515) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:816) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632) 

目前还没找到解决办法,等我知道原因了,找到解决办法了,再回来记录修改下。

广大的网友有知道原因的吗,求告知,万分感谢