Michell Bak
Michell Bak

Reputation: 13252

What's causing this NullpointerException?

I've received a crash report with the following log content:

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 have tried searching for PluginFullScreenHolder across the web, but line 85 appears to be a comment in the classes I've found.

I'm guessing the crash is related to a WebView - possibly because I'm trying to load null, but I'm very unsure of this, especially because I don't see a way for the URL to be null.

I believe the report comes from a Galaxy Nexus (on Android 4.0), if that makes any difference, but I'm not sure. If not, it's a Honeycomb device.

Anyone with experience in PluginFullScreenHolder?

Here's 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 weird thing is that the crash report from Market doesn't mention anything about my code - nothing what so ever - you're looking at the complete log above. It's 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%29

The line in question is:

client.onShowCustomView(mLayout, mOrientation, mCallback);

Upvotes: 4

Views: 2341

Answers (3)

BrainCrash
BrainCrash

Reputation: 13182

Have you tried to initialize "web"?

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

if you declared your variable like this

private WebView web;

You will get the NullpointerExeption, you must initialize the object.

Upvotes: 0

Dalmas
Dalmas

Reputation: 26557

Here is the PluginFullScreenHolder.java source code for android 4.0.

At line 84, you have mWebView.getWebChromeClient() which returns null according to your exception (it is used at line 85 without null check).

A workaround is to set an empty WebChromeClient (which is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts are sent here) :

web.setWebChromeClient(new WebChromeClient());

But this is really strange because it should never be null.

Upvotes: 7

gwvatieri
gwvatieri

Reputation: 5183

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

android.app.Dialog

in the method show().

You might want to take a look to the source code.

Upvotes: 0

Related Questions