We have an Android application, which is stable, working for days without any error. once in a while we experience an application crash, and every time I took a look at the stack trace it seem something like this:
06-05 12:05:58.939: DEBUG/AndroidRuntime(3149): Shutting down VM
06-05 12:05:58.939: WARN/dalvikvm(3149): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): FATAL EXCEPTION: main
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): java.lang.NullPointerException
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.widget.AbsListView.obtainView(AbsListView.java:1304)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): atandroid.widget.ListView.makeAndAddView(ListView.java:1727)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.widget.ListView.fillDown(ListView.java:652)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.widget.ListView.fillGap(ListView.java:623)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2944)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2485)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.os.Handler.handleCallback(Handler.java:587)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.os.Handler.dispatchMessage(Handler.java:92)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.os.Looper.loop(Looper.java:142)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at android.app.ActivityThread.main(ActivityThread.java:4914)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at java.lang.reflect.Method.invokeNative(Native Method)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at java.lang.reflect.Method.invoke(Method.java:521)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-05 12:05:58.949: ERROR/AndroidRuntime(3149): at dalvik.system.NativeStart.main(Native Method)
Note there is only reference to Android internal objects.
There were other time we experienced this, other stack traces ending up also throwing NPE again with Android internal stack trace only, without any reference to any one of our objects or methods in it, in this case it was the widget, and the last time I have seen such NPE it came from the LayoutView, and I’ve also found another question which NPE has been thrown in the GroupView.
The point is that the application works, and I can try to reproduce the crash using the very same scenario a thousand time and not see this happening, but every now and then this happens.
Has anyone else experience this?
Could it be related to the way we have layout our UI components?
Even if you just have an idea, please share…
Thanks,
Adam Zehavi.
The most likely cause is that your
ListViewis being updated before you have calledsetListAdapter()on it. Being intermittent, I would suggest that you maybe have a threading issue here: One thread is causing yourListViewto be updated before another has calledsetListAdapter().