活动线程崩溃

Ark*_*asu 6 java android firebase android-workmanager

遇到了一些ActivityThread我无法理解的崩溃。其中一些指向定期工作的第三方库,如 Workmanager、Firebase 等。其中大多数的根本原因是,DeadSystemExceptionThe core Android system has died and is going through a runtime restart.这种情况如此常见吗?

堆栈跟踪 1:

Fatal Exception: java.lang.RuntimeException: Unable to create service androidx.work.impl.background.systemjob.SystemJobService: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:3689)
       at android.app.ActivityThread.access$1500(ActivityThread.java:207)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1774)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6898)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:3683)
       at android.app.ActivityThread.access$1500(ActivityThread.java:207)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1774)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6898)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Run Code Online (Sandbox Code Playgroud)

堆栈跟踪 2:

Fatal Exception: java.lang.RuntimeException: Unable to create service com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:4506)
       at android.app.ActivityThread.access$100(ActivityThread.java:296)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2165)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:260)
       at android.app.ActivityThread.main(ActivityThread.java:8245)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)
    Caused by java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:4500)
       at android.app.ActivityThread.access$100(ActivityThread.java:296)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2165)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:260)
       at android.app.ActivityThread.main(ActivityThread.java:8245)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:612)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1006)

Run Code Online (Sandbox Code Playgroud)

堆栈跟踪 3:

Fatal Exception: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleSleeping(ActivityThread.java:4909)
       at android.app.ActivityThread.access$2700(ActivityThread.java:242)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2079)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:213)
       at android.app.ActivityThread.main(ActivityThread.java:7620)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪 4:

Fatal Exception: java.lang.RuntimeException: Unable to unbind to service com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService@89f0968 with Intent { cmp=com.ultrahuman.android/com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService }: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleUnbindService(ActivityThread.java:4712)
       at android.app.ActivityThread.access$1800(ActivityThread.java:301)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2187)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8595)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪 5:

Fatal Exception: java.lang.RuntimeException: Unable to create service com.google.android.gms.cast.framework.media.MediaNotificationService: java.lang.NullPointerException: null reference
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:3205)
       at android.app.ActivityThread.-wrap5(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1568)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6124)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)
    Caused by java.lang.NullPointerException: null reference
       at java.util.Objects.requireNonNull(Objects.java:228)
       at com.google.android.gms.common.internal.Preconditions.checkNotNull(Preconditions.java:2)
       at com.google.android.gms.cast.framework.media.MediaNotificationService.onCreate(MediaNotificationService.java:4)
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:3195)
       at android.app.ActivityThread.-wrap5(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1568)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6124)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)

Run Code Online (Sandbox Code Playgroud)

堆栈跟踪 6:

Fatal Exception: java.lang.RuntimeException: Unable to unbind to service com.google.firebase.auth.api.fallback.service.FirebaseAuthFallbackService@762356d with Intent { act=com.google.firebase.auth.api.gms.service.START pkg=com.ultrahuman.android }: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleUnbindService(ActivityThread.java:3684)
       at android.app.ActivityThread.access$1500(ActivityThread.java:206)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1711)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6953)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:590)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleUnbindService(ActivityThread.java:3678)
       at android.app.ActivityThread.access$1500(ActivityThread.java:206)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1711)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6953)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:590)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Run Code Online (Sandbox Code Playgroud)

这分布在各个 Android 版本中(9 / 10 / 11)。用户不会再出现重复崩溃的情况。我们如何缓解这种情况?谢谢!