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

From here:

Does this problem happen every time you debug your project?

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.

As you are using web API in your fragment so sometimes that will send multiple requests on the server and in terms of response, you are getting @null.

W/Binder  (  899): Caught a RuntimeException from the binder stub implementation.
W/Binder  (  899): java.lang.NullPointerException

DeadObjectException extends RemoteException

This Exception means , The object you are calling has died, because its hosting process no longer exists. And check this link for your reference based on DeadObjectException.


In my app i found this bug , but the great thing about this exception is which doesn't occurs in all the devices

after doing lot of R&D i resolved it 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

When i Got this DeadObjectException my component code looks like this

public class TextViewCust extends TextView {

private Context context;
private AttributeSet attrs;
private int defStyle;

public TextViewCust (Context context) {
    super(context);
    this.context=context;
    init();
} 

 public TextViewCust (Context context, AttributeSet attrs) {
      super(context, attrs);
      this.context=context;
      this.attrs=attrs;
      init();
 }

public TextViewCust (Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
      this.context=context;
      this.attrs=attrs;
      this.defStyle=defStyle;
      init();
 }

private void init() {
            //This is the line where i got dead Object Exception 
        Typeface font=Typeface.createFromAsset(getContext().getAssets(), "telugu.ttf");
        this.setTypeface(font);
  }

Note: When i commented the code in init method i never got that exception even a single time


I ran into this exception while running the emulator for a Pixel. However when I ran the same code on a live Samsung 6 with Android 7, the issue was never repeated. After rebooting my macbook the issue was resolved - I suspect that it often occurs with emulators that have been running for a while on a machine that has been running a while.

TLDR; Reboot your machine.


I solved this when I did not called my own method in the onCreate method of the Activity like the init() method in sample code in the answer below. So I have to put all my 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.