Monday, October 2, 2017

Widgets lead to DeadObjectException - Transaction failed on small parcel

Leave a Comment

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

  • my app is working normally on a lot of phones (all but one actually)
  • above crash only happens on one users device (SM-N910C (Samsung Note 4), Android 6.0.1)
  • the user says, those widgets work fine in his launcher

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...

2 Answers

Answers 1

DeadObjectException : 

The object you are calling has died, because its hosting process no longer exists.

Possible Solutions:

1) Override your service's onDestroy() method and watch what event flow leads to it. If you catch DeadObjectException without going through this method, your service should have been killed by the OS.

2) by removing Typeface , this might be because of ttf which i was using from assets folder Please try comment the typeface and test it hope it will work for sure

3) put all your code inside the onCreate. From there you will see what is the culprit like a NullPointerException for example but your code will run smoothly already.

Answers 2

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 Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment