WebView初始化失败,报空

时间:2021-08-28 14:37:53
遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 

21 个解决方案

#1


引用 楼主 qq_25280063 的回复:
遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

#2


引用 1 楼 ngh8897 的回复:
Quote: 引用 楼主 qq_25280063 的回复:

遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("www.baidu.com");

        setContentView(webView);
    }
}

#3


没有  获取  控件  呀 当然   报空了

#4


现在setcontentVIew,再使用loadurl()试一试

#5


引用 2 楼 qq_25280063 的回复:
Quote: 引用 1 楼 ngh8897 的回复:

Quote: 引用 楼主 qq_25280063 的回复:

遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("www.baidu.com");

        setContentView(webView);
    }
}



public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("https://www.baidu.com");

        setContentView(webView);
    }
}


这样还会报空指针吗?,这段代码经我测试没有问题

#6


先setContentView(),楼主是还没入门吗

#7


引用 3 楼 No__Su__oN 的回复:
没有  获取  控件  呀 当然   报空了
我说的就是new WebView(this)报空

#8


引用 6 楼 Smart_YC 的回复:
先setContentView(),楼主是还没入门吗
我也是醉了,setContentView是最基础的显示view好吗,使用布局文件。我也说了,是某些机子有些问题。

#9


引用 5 楼 ngh8897 的回复:
Quote: 引用 2 楼 qq_25280063 的回复:

Quote: 引用 1 楼 ngh8897 的回复:

Quote: 引用 楼主 qq_25280063 的回复:

遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("www.baidu.com");

        setContentView(webView);
    }
}



public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("https://www.baidu.com");

        setContentView(webView);
    }
}


这样还会报空指针吗?,这段代码经我测试没有问题
是的,但存在某些机子上有问题,目前怀疑是sdk问题。

#10


首先,此代码是没有问题的,可以先设置load
其次,url前要添加https://或http://

#11


引用 4 楼 kekegdsz 的回复:
现在setcontentVIew,再使用loadurl()试一试
不好意思,是在new WebView(this)就报错了,初始化报空。

#12


引用 10 楼 dalor 的回复:
首先,此代码是没有问题的,可以先设置load
其次,url前要添加https://或http://
不好意思,是在new WebView(this)就报错了,初始化报空。

#13


把完整代码贴出来。运行环境参数也发下。
我特地试了代码,确实没有错误。

#14


引用 13 楼 dalor 的回复:
把完整代码贴出来。运行环境参数也发下。
我特地试了代码,确实没有错误。
这代码是没有错,只是在某些机子上才会有错。我然后新建一个项目,同样的代码就没有错误。别人告诉我可能是原先项目jar包冲突了,有些机子上面找不到某些代码,所以报空了。yunos系统的机子,yunos的jar包

#15


嗯,这个有可能。

#16


估计跟系统版本有关吧

#17


引用 16 楼 Arnold9009 的回复:
估计跟系统版本有关吧
也有可能,但我一开始就在这个方向查了,没结果。

#18


引用 17 楼 qq_25280063 的回复:
Quote: 引用 16 楼 Arnold9009 的回复:

估计跟系统版本有关吧
也有可能,但我一开始就在这个方向查了,没结果。


楼主问题解决了  我也遇到了同样的问题
机型华为P9 系统Android7.0

#19


要跟踪打印下,一行一行跟踪下,没取到控件值。

#20


删除data/data/packagename/app_webview 文件夹就可以了,缓存问题

#21


楼主 这个问题有结论吗 我也遇到了一样的问题,希望能得到帮助

#1


引用 楼主 qq_25280063 的回复:
遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

#2


引用 1 楼 ngh8897 的回复:
Quote: 引用 楼主 qq_25280063 的回复:

遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("www.baidu.com");

        setContentView(webView);
    }
}

#3


没有  获取  控件  呀 当然   报空了

#4


现在setcontentVIew,再使用loadurl()试一试

#5


引用 2 楼 qq_25280063 的回复:
Quote: 引用 1 楼 ngh8897 的回复:

Quote: 引用 楼主 qq_25280063 的回复:

遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("www.baidu.com");

        setContentView(webView);
    }
}



public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("https://www.baidu.com");

        setContentView(webView);
    }
}


这样还会报空指针吗?,这段代码经我测试没有问题

#6


先setContentView(),楼主是还没入门吗

#7


引用 3 楼 No__Su__oN 的回复:
没有  获取  控件  呀 当然   报空了
我说的就是new WebView(this)报空

#8


引用 6 楼 Smart_YC 的回复:
先setContentView(),楼主是还没入门吗
我也是醉了,setContentView是最基础的显示view好吗,使用布局文件。我也说了,是某些机子有些问题。

#9


引用 5 楼 ngh8897 的回复:
Quote: 引用 2 楼 qq_25280063 的回复:

Quote: 引用 1 楼 ngh8897 的回复:

Quote: 引用 楼主 qq_25280063 的回复:

遇到一个奇怪的问题,初始化WebView的时候报空了。
在new WebView的时候程序崩溃,提示错误是报空。在XML里面布局也是同样问题
而且公司里面只有一个机子有这个问题,当时以为是机子问题,可是我在别的项目这个机子去初始化的时候,又不会有问题,这就奇怪了,只有这个项目,去这个机子上初始化WebView的时候,才会出现问题,应该是代码问题吧?
广大的网友有没有知道原因的,求告知!附上错误信息:
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) 


com.yunos.tvtaobao.WebActivity.onCreate(WebActivity.java:17)  

这一行 上下相关的代码呢来看看

public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("www.baidu.com");

        setContentView(webView);
    }
}



public class WebActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        webView.loadUrl("https://www.baidu.com");

        setContentView(webView);
    }
}


这样还会报空指针吗?,这段代码经我测试没有问题
是的,但存在某些机子上有问题,目前怀疑是sdk问题。

#10


首先,此代码是没有问题的,可以先设置load
其次,url前要添加https://或http://

#11


引用 4 楼 kekegdsz 的回复:
现在setcontentVIew,再使用loadurl()试一试
不好意思,是在new WebView(this)就报错了,初始化报空。

#12


引用 10 楼 dalor 的回复:
首先,此代码是没有问题的,可以先设置load
其次,url前要添加https://或http://
不好意思,是在new WebView(this)就报错了,初始化报空。

#13


把完整代码贴出来。运行环境参数也发下。
我特地试了代码,确实没有错误。

#14


引用 13 楼 dalor 的回复:
把完整代码贴出来。运行环境参数也发下。
我特地试了代码,确实没有错误。
这代码是没有错,只是在某些机子上才会有错。我然后新建一个项目,同样的代码就没有错误。别人告诉我可能是原先项目jar包冲突了,有些机子上面找不到某些代码,所以报空了。yunos系统的机子,yunos的jar包

#15


嗯,这个有可能。

#16


估计跟系统版本有关吧

#17


引用 16 楼 Arnold9009 的回复:
估计跟系统版本有关吧
也有可能,但我一开始就在这个方向查了,没结果。

#18


引用 17 楼 qq_25280063 的回复:
Quote: 引用 16 楼 Arnold9009 的回复:

估计跟系统版本有关吧
也有可能,但我一开始就在这个方向查了,没结果。


楼主问题解决了  我也遇到了同样的问题
机型华为P9 系统Android7.0

#19


要跟踪打印下,一行一行跟踪下,没取到控件值。

#20


删除data/data/packagename/app_webview 文件夹就可以了,缓存问题

#21


楼主 这个问题有结论吗 我也遇到了一样的问题,希望能得到帮助