Android: NullPointerException in android.app.ActivityThread $ PackageInfo $ ServiceDispatcher.doConnected (ActivityThread.java:1012)

I get

NullPointerException at android.app.ActivityThread$PackageInfo$ServiceDispatcher.doConnected(ActivityThread.java:1012)

My application is not even in the stack trace, so I have no idea what is going on.

I am trying to connect to the service when this happens.

How can I fix this problem?

+4
source share
1 answer

This is probably too old for my answer to use it, but in case anyone else has this problem, thatโ€™s what it was for me. I am using a newer version of the SDK, so I get this problem on line 1061.

This happened to me because I was passing a null ServiceConnection object to the bindService function.

It was useful to look at the SDK code in my case - although line numbers do not add up due to differences in version, the general code is probably the same (and I knew which method to check):

 1097 // If there was an old service, it is not disconnected. 1098 if (old != null) { 1099 mConnection.onServiceDisconnected(name); 1100 } 1101 // If there is a new service, it is now connected. 1102 if (service != null) { 1103 mConnection.onServiceConnected(name, service); 1104 } 

mConnection was pretty much the only thing that made sense to be null.

+7
source

All Articles