Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix NPE in ViewRoot#updateBidiOptions?

In the developer console on the Android market we are getting a lot of stack traces like this (sent in by users when our app crashes):

java.lang.NullPointerException at
android.view.ViewRoot.updateBidiOptions(ViewRoot.java:290) at
android.view.ViewRoot.performTraversals(ViewRoot.java:737) at
android.view.ViewRoot.handleMessage(ViewRoot.java:1792) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:143) at
android.app.ActivityThread.main(ActivityThread.java:5068) 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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at
dalvik.system.NativeStart.main(Native Method)

We have not been able to reproduce the crash and also when we check the Android source code, there is no method called updateBidiOptions. The user comments seems to suggest that the crash happens when they focus on an EditText. Many of the users also mention that this happens on HTC Desire HD but it is not crashing on the Desires we have here.

How can we fix this problem?

like image 249
perja Avatar asked Sep 10 '25 23:09

perja


2 Answers

Usually when you see a NPE in a stacktrace that does not involve any of your own code, at some point you have passed null as a parameter to the Android framework where you are not supposed to.

So if you have any place in the code where you might be in doubt if you are passing null as an option, double check that you are allowed to do that.

Otherwise, what Android version is this crash happening on?

If we have the correct source for android.view.ViewRoot.updateBidiOptions(ViewRoot.java:290) we should be able to see what reference is being referred and is a null reference. And step back from there until we see a reference provided from your source (that is probably also null).

However, when I look at the source for ViewRoot.java in my gingerbread clone, I don't even see the method updateBidiOptions(). Thus I need to know the approximate Android version being used, to give an educated guess on which reference it might be.

like image 152
Bjarke Freund-Hansen Avatar answered Sep 12 '25 14:09

Bjarke Freund-Hansen


Just to finish up this one: the problem was with a custom ROM (B0.8). The problem resolved itself when that ROM was updated to B0.8.4 which no longer calls updateBidiOptions.

like image 32
perja Avatar answered Sep 12 '25 14:09

perja