DeadSystemException start service Android 7

喜你入骨 提交于 2019-12-03 13:00:00

问题


For the past few weeks, I have on my crash reporter:

Fatal Exception: java.lang.RuntimeException: Unable to start service com.####.MyService@ef705d8 with Intent { act=HIDE cmp=com.####/.MyService (has extras) }: java.lang.RuntimeException: android.os.DeadSystemException
       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3344)
       at android.app.ActivityThread.-wrap21(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1583)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6121)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

This crash is present on:

  • all Samsung devices 7.0

  • all Nexus devices on 7.1.2

Note:

  • It is not due to a recent update of our application, just an OS updates on theses phones.

  • It is a very very frequent crashes (by far our biggest).

  • Our users don't report crashes than before (is this crash actually visible for the user?)

  • We are not able to reproduce it on our side

  • As you can see into the stack trace, the code impacted is system only. Not much I can do from my side to try and catch and handle the issue.

I checked the thread Android DeadSystemException but that doesn't help me much.

I know that DeadSystemException is:

The core Android system has died and is going through a runtime restart. All running apps will be promptly killed.

Is there anything we can do but to say "that's system, we cannot do anything"?


回答1:


When the device is being restarted, you cannot run an app. Any app, not just yours but any given app cannot run when the device is restarting. AFAIK it occurs when you try to do something when the system crashes. Meaning if the system crashes and as it restarts your app starts a service or does something you get that error.

Meaning the exception is not connected to your app, but the Android OS and there is nothing you can do about it.

The crash being related to starting a service is because that is what your app did when the system crashed.

So: The error is something the system threw because your app did something when the system did a run-time reboot. There is nothing you can do about this, as you cannot control the Android OS from an app.




回答2:


I've had the same issue. I implemented a service that uses the android SensorService. In some point of the time, two things happened but I still don't know which one caused the other. 1) The runtime restarted 2) The android SensorService died. I have implemented a default unhandled exceptions handler because I was debugging some other stuff on my app. I noticed that such handler, at least sometimes was catching that exception.

I followed this tutorial to implement it https://doandroid.wordpress.com/2011/11/19/writing-crash-reports-into-device-sd-card/

So, supposing that you implement this handler and it is actually being called when the system dies, you can add some sort of validations inside the handler such that if the exception is the DeadSystemException, you can set up an alarm to restart your application in let's say, 5 minutes or something.

This is of course not an ideal solution, but at least might be a workaround to your problem until you figure out what is really going on with the system.

Some information about how to restart you app programmatically: Force application to restart on first activity




回答3:


Your app crashed because of android OS system dies. Here is the reference. https://developer.android.com/reference/android/os/DeadSystemException The core Android system has died and is going through a runtime restart. All running apps will be promptly killed.



来源:https://stackoverflow.com/questions/44408197/deadsystemexception-start-service-android-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!