Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeadObjectException with com.google.android.gms

I'm getting a frequent crash with the log below. It doesn't reference my application code but I'm guessing it may have something to do with GoogleApiClient connecting/disconnecting. Anyone get anything similar to this? I haven't been able to find anything on here.

java.lang.IllegalStateException: android.os.DeadObjectException
  at com.google.android.gms.internal.ao.removeAllListeners(Unknown Source)
  at com.google.android.gms.internal.ap.disconnect(Unknown Source)
  at com.google.android.gms.common.api.b.n(Unknown Source)
  at com.google.android.gms.common.api.b.a(Unknown Source)
  at com.google.android.gms.common.api.b$2.onConnectionSuspended(Unknown Source)
  at com.google.android.gms.internal.r.y(Unknown Source)
  at com.google.android.gms.internal.q$a.handleMessage(Unknown Source)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:5102)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
  at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.DeadObjectException
  at android.os.BinderProxy.transact(Native Method)
  at com.google.android.gms.internal.an$a$a.a(Unknown Source)
  ... 15 more

Possibly where it's happening. I added a try/catch to catch the exception

mGApiClientMgr.addTask(mGApiClientMgr.new GoogleApiClientTask() {
            @Override
            public void run() {
                Log.d(LOG_TAG, "Refreshing data set.");
                Location location;
                try {
                    location = LocationServices.FusedLocationApi.getLastLocation(getGoogleApiClient());
                    onLocationChanged(location);
                }
                catch(IllegalStateException ex) {
                    // TODO
                }
            }
        });

where addTask does:

  private final LinkedBlockingQueue<GoogleApiClientTask> mTaskQueue = new LinkedBlockingQueue
        <GoogleApiClientTask>();

  mTaskQueue.offer(task);
like image 625
ono Avatar asked Sep 29 '14 16:09

ono


Video Answer


1 Answers

This seems related to handlers and message passing...Based on below snippet from your stack trace, gms is seeing a DeadObjectException when trying to process a message on the looper. Even though the stack trace shows gms related, it could have be triggered by your code.

   at com.google.android.gms.internal.q$a.handleMessage(Unknown Source)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:136)

This exception is seen if the message its trying to access belong to a process that has since exited/killed. Do a code search for all handler sendMessage* message dispatch calls, through out your code. Even this may not catch all instances as some gms calls could result in handler message dispatches.

Also, check if any of your background services, or activities that allocated handler messages, are exiting. Android could be destroying them depending on life cycle states, try overriding onDestroy.

In all your activities/services, any where you make calls to gms api, check the objects you create and pass to gms; If they die, those objects are not valid any more.

like image 144
ashoke Avatar answered Oct 29 '22 19:10

ashoke