Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeadSystemException start service Android 7

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"?

like image 859
stankocken Avatar asked Jun 07 '17 09:06

stankocken


People also ask

What is the cause of the Android deadsystemexception?

One cause was a bug in the notification service of Android version 7 and 8. It was caused by using "vibration pattern" in the notifications, which throws an ArrayOutOfBoundsException. This leads the whole system to crash and post a DeadSystemException.

How do you handle a dead system exception in an application?

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.

What is the deadsystemexception in the HockeyApp crash report?

Currently, we are experiencing a DeadSystemException in our HockeyApp crash reporting. It occurs on Android 7.0 and Android 7.1. We don't experience this exception in the previous version of our application (they are currently both used by users), so I guess this exception is caused by some code change. But stack trace is not very helpful for this.

What is the cause of deadsystemexception in Salesforce?

It was caused by using "vibration pattern" in the notifications, which throws an ArrayOutOfBoundsException. This leads the whole system to crash and post a DeadSystemException. For further details you can refer to this Medium article here. Show activity on this post.


2 Answers

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.

like image 111
Zoe stands with Ukraine Avatar answered Oct 07 '22 16:10

Zoe stands with Ukraine


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

like image 33
Roger Avatar answered Oct 07 '22 16:10

Roger