mercredi 5 juillet 2017

Why Android crashes instead of showing the error in debug mode

So after a while, I found a reason which causes crashing in my app in debug mode!! I replaced a fragment with another one, but it crashes and exit from debug mode. In same sample it works fine and finally, I got the problem that was about my forgetfulness about the implementation of its listener. Though, in the code, there was a throw command for unimplementation!

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof OnFragmentInteractionListener) {
        mListener = (OnFragmentInteractionListener) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement OnFragmentInteractionListener");
    }
}

In Android Monitor when the crash happens, only this lines are appended:

07-05 08:05:54.797 6171-6171/com.shoniz.saledistributemobility
D/AndroidRuntime: Shutting down VM

07-05 08:05:54.799 6171-6171/com.shoniz.saledistributemobility I/art: System.exit called, status: 2

07-05 08:05:54.799 6171-6171/com.shoniz.saledistributemobility I/AndroidRuntime: VM exiting with result code 2, cleanup skipped.

07-05 08:05:54.801 1303-1576/system_process D/GraphicsStats: Buffer count: 3

So, is there any way that forces Android Studio to show the reason of crash to save our time?!





Aucun commentaire:

Enregistrer un commentaire