DeadObjectException 与 com.google.android.gms [英] DeadObjectException with com.google.android.gms

查看:38
本文介绍了DeadObjectException 与 com.google.android.gms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常遇到下面的日志崩溃.它没有引用我的应用程序代码,但我猜它可能与 GoogleApiClient 连接/断开连接有关.有人得到类似的东西吗?我在这里找不到任何东西.

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

可能发生的地方.我添加了一个 try/catch 来捕获异常

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
                }
            }
        });

addTask 的作用:

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

  mTaskQueue.offer(task);

推荐答案

这似乎与处理程序和消息传递有关...根据堆栈跟踪中的以下片段,gms 看到 DeadObjectException 尝试 在looper上处理message.即使堆栈跟踪显示与 gms 相关,它也可能由您的代码触发.

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)

如果它尝试访问的 message 属于已退出/终止的进程,则会出现此异常.对所有 handler sendMessage* 消息调度进行代码搜索调用,贯穿你的代码.即使这样也可能无法捕获所有实例,因为某些 gms 调用可能会导致 handler 消息分派.

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.

此外,检查您的任何后台服务或分配了 handler 消息的活动是否正在退出.Android 可能会破坏它们 根据生命周期状态,尝试覆盖 onDestroy.

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.

在您所有的活动/服务中,任何您调用 gms api 的地方,检查您创建并传递给 gms 的对象;如果它们死亡,这些对象将不再有效.

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.

这篇关于DeadObjectException 与 com.google.android.gms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆