android – Odd logcat error when switching to new fragment-ThrowExceptions

Exception or error:

I haven’t encountered a stack trace such as this. It’s particularly weird because I can only get the error to be thrown when debugging. (Running the app without debugging does not yield this error). This happens upon selecting a particular page from my navigation drawer. I have just recently switched from activities to fragments and I may not have handled my fragment transactions correctly. I would appreciate any input! Thanks a lot guys, happy holidays!

Here’s the stack trace:

Process: com.kohlerbear.whowascnscalc, PID: 2415
java.lang.NullPointerException: Attempt to read from field 'boolean' on a null object reference
        at android.os.Handler.handleCallback(
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(

And here is how I am handling my fragment change (Not sure if this is the problem, just judging by the fact that the trace mentions the backstack). The app crashes (again, only when debugging) regardless of whether or not I call ft.addToBackStack(null) .

Fragment frag = new ThirdScreenFragment(); 
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(, frag);

Any ideas and input are appreciated 🙂

How to solve:

I found a workaround for this issue. Put a breakpoint in the method and set break condition to false.

enter image description here


I recently ran into the same error message in Android studio. I could run my application but once I tried to start debugging, I would receive “Attempt to read from field ‘boolean’ on a null object reference”. The solution was to select in Android Studio, Run (toolbar) -> View Break Points -> disable each break point one by one until debugging started to work again. Doing this doesn’t remove the break point entirely it simply disables them, so there’s no need to worry that you’d need to remove all your break points to find the one causing the issue. It seems that one of the break points I had setup in a IntentService class was causing the issue. I’m not sure why it was causing an issue, but it seemed to fix this error for me.

Leave a Reply

Your email address will not be published. Required fields are marked *