如何捕获android.os.DeadObjectException

时间:2017-06-10 15:22:47

标签: java android exception

我在崩溃中遇到了崩溃,这是由android.os.DeadObjectException引起的。我搜索了这个问题并找到了一些答案:

您呼叫的对象已经死亡,因为其托管过程已不复存在。

我找到了关于何时发生此异常的答案,如果使用服务,但我的情况不同。

非常难以引起这种异常,它非常随机。

我使用带有视图的底部导航栏(NO片段),这个异常是通过添加视图引起的。这是来自crashlytics的完整堆栈跟踪:

Fatal Exception: java.lang.RuntimeException: Adding window failed
   at android.view.ViewRootImpl.setView(ViewRootImpl.java:555)
   at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:313)
   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:86)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3176)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2488)
   at android.app.ActivityThread.access$900(ActivityThread.java:153)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5438)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
   at android.os.BinderProxy.transactNative(Binder.java)
   at android.os.BinderProxy.transact(Binder.java:503)
   at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:746)
   at android.view.ViewRootImpl.setView(ViewRootImpl.java:543)
   at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:313)
   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:86)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3176)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2488)
   at android.app.ActivityThread.access$900(ActivityThread.java:153)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5438)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

我认为这也是由java.lang.RuntimeException: Could not read input channel file descriptors from parcel.

引起的

堆栈追踪:

java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
    at android.view.InputChannel.nativeReadFromParcel(Native Method)
    at android.view.InputChannel.readFromParcel(InputChannel.java:148)
    at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:759)
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:531)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:310)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
    at android.widget.Toast$TN.handleShow(Toast.java:425)
    at android.widget.Toast$TN$1.run(Toast.java:331)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

0 个答案:

没有答案