Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullPointerException in handleStopActivity -- No reference to my code in stack trace

Tags:

java

android

I'm a bit at a loss, here. I've been seeing a steadily increasing number of these NullPointerExceptions in handleStopActivity. I suspect that the increase coinicides with the increase in 2.2 upgrades to Droid owners, though that's just a guess. I've never seen the crash myself, and the stack trace provided by the market does not mention any of the classes I've written. As such, I have no idea where to start in fixing the problem.

java.lang.NullPointerException
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3674)
at android.app.ActivityThread.access$2600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2153)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
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)

Since I don't know the cause, I also don't know what information to provide to aid in diagnosis, so I'll give an overiew: My app is WootWatcher. It tracks Woot.com and notifies users of new items for sale. It does this by means of a service that runs in a separate process. The service and the main activity communicate with each other via aidl interface and callback. I also make use of message handlers in both the service and activity, and frequently spawn threads for expensive tasks.

like image 709
BenTobin Avatar asked Aug 18 '10 15:08

BenTobin


1 Answers

Looking back at this 4-year old question, I realize I should be able to diagnose it, but unfortunately I can't find any version of AOSP for which these lines match up. The Droid must have used some altered version of the source that wasn't made available.

That said, Froyo's handleStopActivity() doesn't have many opportunities for a null pointer exception. The most likely one would point to Activity.finish() when the Activity has already been stopped, or is in the process of being stopped.

This usually happens when you register listeners that eventually call finish() and you don't unregister those listeners in onPause().

like image 65
BenTobin Avatar answered Oct 05 '22 22:10

BenTobin