如何修复“由android.os.DeadObjectException引起”?

时间:2019-02-06 14:53:51

标签: android runtimeexception deadobjectexception

我最近在我的应用程序中遇到此错误,该错误消息显示DeadObjectException,它从未发生过,并且在Fabric上收到有关此错误的通知(该应用程序已安装在成千上万的设备上)。 这是在OS版本6的Galaxy J7 pop上发生的。

这是Fabric的日志:

Unable to stop service com.XXX.XXX.XXX.XXXX.services.IndoorOutdoorService@2c92060: java.lang.RuntimeException: Failure from system
android.app.ActivityThread.handleStopService

android.os.BinderProxy.transactNative (Binder.java)
android.os.BinderProxy.transact (Binder.java:503)
android.app.ActivityManagerProxy.broadcastIntent (ActivityManagerNative.java:3633)
android.app.ContextImpl.sendBroadcast (ContextImpl.java:847)
android.content.ContextWrapper.sendBroadcast (ContextWrapper.java:410)
com.XXX.XXX.XXX.XXXX.services.IndoorOutdoorService.broadcastShutdown (IndoorOutdoorService.java:230)
com.XXX.XXX.XXX.XXXX.services.IndoorOutdoorService.onDestroy (IndoorOutdoorService.java:59)
android.app.ActivityThread.handleStopService (ActivityThread.java:4165)
android.app.ActivityThread.access$2500 (ActivityThread.java:231)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1931)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:7422)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

我根据日志查看了行,但是我不明白怎么了。

@Override
    public void onDestroy() {
        IndoorOutdoorLogger.d(IndoorOutdoorService.this, TAG, "IndoorOutdoorService was destroyed.");
        cancelManager();
        DetectionResult.saveDetectionTimeToCache(IndoorOutdoorService.this, System.currentTimeMillis());
        IndoorOutdoorLogger.remove(logListener);
        broadcastShutdown();
        this.releaseWakeLock();
        super.onDestroy();
    }

// Broadcast a detection to the IO services.
private void broadcastShutdown() {
    Intent i = new Intent(SHUTDOWN);
    sendBroadcast(i);
}

是什么原因导致此错误,如何防止再次发生?

0 个答案:

没有答案