Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 219
funroll Avatar asked Mar 21 '14 22:03

funroll


People also ask

How do I create an exception breakpoint?

How to add an Exception Breakpoint? Step 1 − To add an exception breakpoint, first move to breakpoint navigator in xcode. Step 2 − Click on the + option at the left bottom of the navigator and select Exception breakpoint. Once you select exception breakpoint, it will be added to our code.

Can you set breakpoints in Android Studio?

To set a breakpoint in Android Studio, you need to navigate to a specific line of code and then click in the gutter next to the line number. To unset a breakpoint, you need to click an existing breakpoint in the gutter to make it disappear.

What is breakpoint exception?

Exception breakpoints: suspend the program when Throwable or its subclasses are thrown. They apply globally to the exception condition and do not require a particular source code reference.

What is Java exception breakpoint?

Exception Breakpoint: This type of breakpoint is used to halt execution when a specified exception type is thrown at any time during execution. To set an exception breakpoint in Eclipse, use the "Run -> Add Java Exception Breakpoint..." menu item.


1 Answers

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.

like image 112
CJBS Avatar answered Oct 20 '22 10:10

CJBS