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);
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.
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.
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.
Related
I have an app that can have multiple WebViews at the same time. Every once in a while the app crashes with a native error
SIGTRAP: Trace/breakpoint trap
at 0x7a587dd494(/data/app/com.android.chrome-7kzKsZs3wawWfQ1TQ0h58w==/base.apk!/lib/arm64-v8a/libmonochrome.so:25011348)
I was able to track it down to a WebView renderer issue which i can simulate by loading a faulty javascript like webView.evaluateJavascript("javascript:(function() { txt = \"a\"; while(1){ txt += \"a\"; } })();", null);.
I am now trying to figure out what page causes the problem in the production app. For that I am overriding WebViewClient.onRenderProcessGone() and want to log the loaded URL at that point. The problem that I have is that, since I have multiple WebViews, I cannot be sure that onRenderProcessGone() is called first on the one that actually caused the crash.
From the WebViewClient doc: Multiple WebView instances may be associated with a single render process. onRenderProcessGone will be called for each WebView that was affected.
My question is, in WebViewClient.onRenderProcessGone(), how can I know which WebView/WebViewClient has caused the crash?
This question got answered in the android-webview-dev google group. Unfortunately there is currently no way to know which webview has crashed.
I am getting a NullPointerException at SuggestionSpan. (Stack trace included below). As the stack trace does not include any of my code, I have absolutely no idea where to start debugging.
The error can be reproduced whenever I press space (or select a word) while using an EditText. I tried multiple keyboards including the stock Android one but the same error appears.
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.text.style.SuggestionSpan.<init>(SuggestionSpan.java:128)
at android.text.style.SuggestionSpan.<init>(SuggestionSpan.java:101)
at android.widget.SpellChecker.createMisspelledSuggestionSpan(SpellChecker.java:392)
at android.widget.SpellChecker.onGetSuggestions(SpellChecker.java:300)
at android.view.textservice.SpellCheckerSession.handleOnGetSuggestionsMultiple(SpellCheckerSession.java:198)
at android.view.textservice.SpellCheckerSession.access$000(SpellCheckerSession.java:86)
at android.view.textservice.SpellCheckerSession$1.handleMessage(SpellCheckerSession.java:112)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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)
EDIT: I can only reproduce the error on my Nexus S with 4.0.3, but not on emulators with other OS versions. Weird.
EDIT 2: Strange thing happened! I just dragged an EditText into another activity and the same thing happens. No code is attached to it nor any XML changes made to it.
After days of investigation, it turns out that getResources().getConfiguration().locale is null. I am not sure if it is a problem specific to some versions of Android / some devices (mine is Nexus S running 4.0.3).
But I worked around this issue by checking in the constructor of the Activity (since the context given to the SuggestionSpan is my Activity) whether the locale is null, and then set it to the default one if it is.
// to prevent a weird bug where locale is null
Configuration config = getResources().getConfiguration();
if (config.locale == null)
config.locale = Locale.getDefault();
That's what I did. I am quite sure it's not the best way though. Anyone have any more ideas?
I'm getting excessive crash reports from users on a Samsung Vibrant Galaxy S. After searching around for solutions to this issue, the only thing I came across was an open issue over at Google Code: http://code.google.com/p/android/issues/detail?id=4599
The thread suggests extending MapView and catching the exceptions. Is this the best approach, or is there something better? I'd like to completely fix this issue rather than throw a bandage on it.
Here's the Stack Trace:
java.lang.IllegalArgumentException: wrong image size: 192 192
at com.google.googlenav.map.MapTile.getImage(Unknown Source)
at com.google.googlenav.map.Map.drawTile(Unknown Source)
at com.google.googlenav.map.Map.drawMapBackground(Unknown Source)
at com.google.googlenav.map.Map.drawMap(Unknown Source)
at com.google.android.maps.MapView.drawMap(MapView.java:1048)
at com.google.android.maps.MapView.onDraw(MapView.java:486)
at android.view.View.draw(View.java:6597)
at android.view.ViewGroup.drawChild(ViewGroup.java:1533)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1260)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1260)
at android.view.View.draw(View.java:6600)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1533)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1260)
at android.view.View.draw(View.java:6600)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1884)
at android.view.ViewRoot.draw(ViewRoot.java:1374)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1139)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
Hopefully someone else will show up with another answer to prove me wrong, but in my personal experience with device-specific issues, catching the exceptions often seems to be the best you can do.
Edit regarding your comment below: That is a point, and I did run into some new problems with specific devices using customised WebView code when extending WebView once.
There are a ton of people on here with far more experience than me, and I hope one of them will drop in to give a more definitive answer or less hacky solution, but if necessary, you could always use android.os.Build.DEVICE, android.os.Build.MODEL and/or android.os.Build.PRODUCT to determine whether the app is running on a Samsung Vibrant Galaxy S, and (via reflection) use the custom MapView class only if it is.
May be You have done mistake here, so change the code to correct form, or enter
<uses-library android:name="com.google.android.maps" // in manifest under inside applicaiton tag
android:required="true"/>
//wrong usage of activity
public class A extends Actvitiy
{
}
//correct usage
public class A extedns MapsActivity
{
//your all program...
}
The following error comes from Android (WebView) and not directly from my own code:
04-28 12:36:15.174: ERROR/Web Console(7604):
Uncaught TypeError: Cannot call method 'getItem' of null at http://m.youtube.com/:844
I am really not doing anything special other than loading that URL into WebView. Most of the time I don't get this error, so I am assuming this could be pointing to some unreliable network conditions? Perhaps youtube.com too busy?
It's hard to tell. Regardless, I would like to at least have an idea what could be causing this and whether I can catch that error so that I can better handle it.
Again, my own code has no knowledge of what getItem is. On the other hand, when this problem occurs, the YouTube page on my WebView is simply empty.
Insights?
EDIT: I have been looking for documentation about the proposed WebSettings.setDomStorageEnabled(true). The only hint I have been able to find so far was in this SO thread: As I mentioned earlier, this problem occurs very rarely and haven't occurred since I posted my question. So I must understand a little more about the connection between this and "DOM storage" before I can devise a way to test/verify whether this solves the problem.
Also, I just encountered another error message (with benign results, so it seems):
05-02 00:44:45.823: ERROR/Web Console(1595):
dojo.back.init() must be called before the DOM has loaded.
If using xdomain loading or djConfig.debugAtAllCosts,
include dojo.back in a build layer.
at http://sj.example.com/ncscript/subsect/j_gs/version/20110428191502.js:164
I can now see some connection to DOM, so it looks like #Brian O'Dell is in the right direction. I just need to understand what WebSettings.setDomStorageEnabled(true) does.
Perhaps you need something like:
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
source
I was trying to use localStorage with Chrome Custom Tabs and I was getting the same error. I have used window.localstorage instead of localStorage and problem was solved.
I also had the same error in the console:
Uncaught TypeError: unable to call null's 'getItem' method
I was using localStorage.getItem to retrieve the value, so I changed it to window.localStorage.getItem and fixed the problem
I see this exception sporadically raising up in my application (in the wild).
The WebView is used to display a jpg (using the zoom/scroll-capabilities of the Android version/the device instead reinventing the wheel and do all the reflection stuff).
I have no idea why this exception eventually could come up. Basically I can only think of an Android bug.
What I do (everything in GUI thread):
display a thumbnail as preview first
set getSettings().setBuiltInZoomControls(false)
when the regular picture is loaded, display that one instead
set getSettings().setBuiltInZoomControls(true)
Why setting ZoomControls on/off: The thumb should not be zoomable, as the WebView resets this on loadData as soon as the regular picture is available and displayed. Would be some bad user experience.
Example device this is happening:
HTC Desire#htc_wwe/htc_bravo/bravo/bravo:2.2/FRF91/226611:user/release-keys
I have exactly the same device/software and it never happend to me...
Any ideas?
Regards,
Oliver
I don't like to answer myself, but littleFluffyKitty did not (only in comment).
Solution is in How to safely turn WebView zooming on and off as needed
a) create your own WebView class
public class MyWebView extends WebView {
b) add in it's onDestroy() method:
getSettings().setBuiltInZoomControls(true);
That's it. Thanks to that, no more of those Exceptions show up.