7

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.

Community
  • 1
  • 1
funroll
  • 35,925
  • 7
  • 54
  • 59
  • 2
    For google indexing, here's some text embedded in the image: Breakpoint Condition Error Problem processing VM event: Breakpoint: 'Any exception' Error: Failed to evaluate breakpoint condition '!(this instanceof java.lang.ClassNotFoundException)' Reason: Cannot find source class for current stack frame Would you like to stop at the breakpoint? – funroll Mar 21 '14 at 22:10
  • This doesn't help answer your question very much, but there's bug https://code.google.com/p/android/issues/detail?id=59136 which I haven't gotten around to investigating yet. – Scott Barta Mar 22 '14 at 15:02
  • I'm still running into this problem with android studio 1.2. Class filters don't seem to be working and I get the above error message when I use the ClassNotFound exception. Any ideas? – TWilly May 20 '15 at 14:42

2 Answers2

1

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.

Community
  • 1
  • 1
CJBS
  • 15,147
  • 6
  • 86
  • 135
  • @MooingDuck Under Breakpoints, do you have both "Exception Breakpoints" and "Java Exception Breakpoints" checked? – CJBS Aug 28 '15 at 21:45
  • Ah, it may have been the case that I had 'Exception Breakpoints' checked as well, which would cause a problem. I'm not certain. – Mooing Duck Aug 28 '15 at 21:56
  • I looked a little further into this. I've found that I encounter this situation only when first starting debugging on an application during its launch phase. The exception is usually at "java.lang.ClassNotFoundException" in the BootClassLoader. One way to handle this would be to put "!(this instanceof BootClassLoader)" as part of the Condition expression on the Breakpoints window for "Java Exception Breakpoints" -> "Any exception". Another way is to start the app without debugging, then attach after initialization. Finally, you could uncheck "Caught exception", as the exception is handled. – CJBS Aug 28 '15 at 22:10
0

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

Community
  • 1
  • 1
Jens
  • 27
  • 2