I am getting a mystery exception reported via the Android Market; a NullPointer in TextView getLeftFadingEdgeStrength(). I have never observed the exception on any of my test devices. It appears to be effecting a minority of users but I cannot trace it to a specific version of Android or release of my software.
The stack trace vanishes somewhere in the platform UI code, without reference to anything from my application. I’ve taken a fairly thorough search on Google and here for any hint of the problem, but without success.
I suspect it might be something to do with using a marquee ellipsize setting in one of my TextViews… and that the way I am doing this somehow exposes a bug in the UI widget code on some platforms or versions. But this is conjecture and I’m loath to spend too much time diving through the platform code chasing theories.
So, I thought I’d post the issue here and see if anyone has encountered a similar problem or can help to hone in on the precise issue.
Stack trace follows:
java.lang.NullPointerException
at android.widget.TextView.getLeftFadingEdgeStrength(TextView.java:7321)
at android.view.View.draw(View.java:7004)
at android.view.View.buildDrawingCache(View.java:6695)
at android.view.ViewGroup.onAnimationStart(ViewGroup.java:1259)
at android.view.ViewGroup.drawChild(ViewGroup.java:1505)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6936)
at android.widget.FrameLayout.draw(FrameLayout.java:357)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1901)
at android.view.ViewRoot.draw(ViewRoot.java:1530)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1266)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1868)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)
In case somebody else stumbles across this issue, I have one user reporting exact same crash on Android 2.3.5 device.
nulljava.lang.NullPointerException
at android.widget.TextView.getLeftFadingEdgeStrength(TextView.java:7449)
at android.view.View.draw(View.java:7004)
at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
at android.view.View.draw(View.java:6936)
…
While I was not able to determine the exact reason for the crash, in my case I was able to resolve it by replacing android:ellipsize=”marquee” attribute in couple of TextViews to android:ellipsize=”end”. (According to Android source the crash occurs in getLeftFadingEdgeStrength method if the the text view is set to marquee.)
The same code worked without issues on many devices and Android versions, so the crash was limited to only a small number of devices. What was somewhat specific to this particular device was that it was using an RTL language AND the offending TextView was involved in an animation.