funroll
funroll

Reputation: 37093

Android Studio: Create well-behaved Exception Breakpoint

I just used Android Studio to make an unmodified empty Android app. I'm trying to set an exception breakpoint.

The default exception breakpoint triggers repeatedly. So I added !(this instance of java.lang.ClassNotFoundException) as a condition, as suggested in this question.

However, I still get interrupted by my exception, this time with a modal dialog box:

Breakpoint Condition Error screenshot

How do I make an exception breakpoint that will stay silent until something exceptional happens?

Edited to clarify: I don't want to make a breakpoint for a specific exception, I want a general exception breakpoint that I can leave on at all times.

Upvotes: 7

Views: 3347

Answers (2)

CJBS
CJBS

Reputation: 15685

The key here is to use class filters in conjunction with configuration to break on all errors, setting them to very high-level namespaces.

  1. Check the Class filters checkbox to enable class filtering. Then click the ... (elipsis) button to open the Class Filters dialog.
  2. Specify class namespace patterns by clicking on the Add Pattern (Add Pattern) button. Enter:

    • com.myapp.* (replace this with the namespace prefix of your app)
    • java.*
    • android.*
    • Add any additional namespaces as necessary (e.g. 3rd party libraries)

Class Filters

  1. Press OK

See here for full instructions.

Upvotes: 1

Jens
Jens

Reputation: 27

Android Studio is essentially IntelliJ IDEA. You have got to use the + button in the top left corner of the Breakpoints screen to add a breakpoint for a specific exception.

See the following thread for details: How to use Intellij Idea's exception breakpoints

Upvotes: 0

Related Questions