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.

My issue lies within the catch statement. The try executes, but the Exception is seemingly never caught and will not print to the Debugger. The results state that an Exception was never handled and a FindElementException was thrown, although that is exactly what I’m trying to catch.