Unable to catch exception using debugger

Disclaimer: I’m using the 3rd edition of the book

Hello there,

I’m new to programming and was going through the book and am stuck at using the debugger to catch exceptions.

In the book, it mentions that I can choose the “Runtime Exception” and launch the app with debugger attached. When I do this, the debugger isn’t able to catch any exception. I’ve attached the page from the book for reference.

Thanks in advance!

You need to comment out the line where you initialize mQuestionTextView in order for the NullPointerException to be raised.
Also could you show us what your code looks like.

As you can see from the pic above, I’ve commented out both mQuestionTextView and mNextButton with the Runtime Exception selected in breakpoint.

When I run the app no breakpoint appears although the Exception does occur as I can see it in my logcat.

Also I’m unable to attach the debugger to process before running the app as I don’t see an option where I can attach the debugger before running the app. I’ve only been able to attach debugger after running the app. Is this an issue ?

Thank you.