What causes this NullpointerException?

I received a crash report with the following log contents:

java.lang.NullPointerException at android.webkit.PluginFullScreenHolder.show(PluginFullScreenHolder.java:85) at android.webkit.WebView$PrivateHandler.handleMessage(WebView.java:8553) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4340) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) 

I tried searching PluginFullScreenHolder over the net, but line 85 seems to be a comment in the classes I found.

I suppose the crash is related to WebView - perhaps because I'm trying to load null , but I'm very unsure of it, especially because I don't see the path for the null url.

I believe the report comes from the Galaxy Nexus (on Android 4.0), if that matters, but I'm not sure. If not, this is a cellular device.

Anyone with PluginFullScreenHolder experience?

Here is my code

 web = (WebView) findViewById(R.id.webView1); web.setBackgroundColor(android.R.color.black); web.getSettings().setJavaScriptEnabled(true); web.getSettings().setPluginsEnabled(true); web.getSettings().setUserAgent(1); web.getSettings().setSupportZoom(false); web.loadUrl("http://www.justin.tv/widgets/live_embed_player.swf?auto_play=true&fullscreen=true&start_volume=100&hostname=www.justin.tv&channel=" + this.getIntent().getExtras().getString("channelName")); 

The strange thing is that the crash report from Market does not mention anything about my code - nothing that ever, you look at the full log above. This is PluginFullScreenHolder.java, no doubt.

Edit 2:

Found the correct class: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/webkit/PluginFullScreenHolder.java#PluginFullScreenHolder.show%28% 29th

Corresponding line:

 client.onShowCustomView(mLayout, mOrientation, mCallback); 
+4
source share
3 answers

Here is the source code of PluginFullScreenHolder.java for Android 4.0 .

On line 84, you have mWebView.getWebChromeClient() , which returns null according to your exception (it is used on line 85 without checking for zero).

The workaround is to set up an empty WebChromeClient (which is called when something happens that can affect the browser user interface, for example, current JavaScript updates and warnings are sent here):

 web.setWebChromeClient(new WebChromeClient()); 

But this is really strange, because it should never be zero.

+7
source

I don't know if it can be useful and not sure about this, but it looks like the exception is related to the superclass:

 android.app.Dialog 

in the show() method.

You might want to check out the source code .

0
source

Have you tried to initialize the web?

 WebView web = new WebView(this); web = (WebView) findViewById(R.id.webView1); 

if you specified your variable as follows

 private WebView web; 

You will get NullpointerExeption, you must initialize the object.

0
source

Source: https://habr.com/ru/post/1386785/


All Articles