I'm getting following exception as soon as I want to show a widget and start listening:
// the relevant stack trace, the rest is comming from my code
// before the code line I posted below
java.lang.RuntimeException: system server dead?
at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:189)
at com.my.app.utils.WidgetUtil.a(SourceFile:231)
...
android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.startListening(IAppWidgetService.java:481)
at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:185)
at com.my.app.utils.WidgetUtil.a(SourceFile:231)
...
The source in my code is following code line:
mAppWidgetManager = AppWidgetManager.getInstance(context);
mAppWidgetHost = new AppWidgetHost(context, R.string.app_name);
mAppWidgetHost.startListening(); // <= this line leads to the crash
Observations
Does anyone has an idea what could cause this? Is this something I can solve in my app? The user says widgets are working fine in his launcher...
So, a simple Google search led me to this definition of a DeadObjectException :-
The object you are calling has died, because its hosting process no longer exists.
From this, it is obvious that you're getting this error because the process that's hosting mAppWidgetHost
has been killed off.
The question now is that why are you getting this error. Overriding and logging onDestroy()
to monitor it could be useful, and definitely is worth a shot. But, since its working on all devices except for one, its more than likely that there's nothing wrong with the onDestroy()
method. Instead, the OS is killing the process off before you can access the object.
So, now why is the OS doing that? This question had me balled up for the longest time. I still do not have a clear answer or solution to this despite a bevy of Google searches with all kinds of related to the problem. But, after spending a considerable amount of time searching, I noticed a peculiarity - most of the issues with this exception, such as this, this and yours happen with Samsung devices.
My guess is that Samsung's underlying architecture leads to this problem. And, while I do not have a reason why this happens or a plausible solution even after a lot more searching, this could still be a start to find a work around targeting Samsung devices.
UPDATE
I searched a bit more and came across this answer. Take a look at the last comment by the question author on the question :-
Finally it is working fine just by a line of code in manifest file, here it is
android:hardwareAccelerated="false"
If anybody get the following kind of errors please try by adding the above line signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
I don't know the logic behind this or if it would work or not. Just sharing it with the hope that it could help you - even in the minutest form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With