Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

debugging - Android Studio IDE: Break on Exception

It seems my Android Studio does not want to break on any exception by default. Enabling break on "Any Exception" starts breaking within actual JDE libraries. Is there any way to force it to break only on exceptions within my code only?

Coming from Visual Studio universe, looking for the default VS debug behavior here.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To break on all exceptions, caught or uncaught:

  1. Open the Breakpoints window via Run -> View Breakpoints.
  2. The Breakpoints dialog appears. In the left pane, scroll to the bottom. Select Any exception under Java Exception Breakpoints
  3. With Any exception selected, on the right pane, configure as follows:
    • Suspend: checked
    • All: selected
    • Condition: !(this instanceof java.lang.ClassNotFoundException)
    • Notifications: both Caught exception and Uncaught exception selected

Breakpoints dialog

  1. Define filters that specify namespaces of libraries that the debugger should break on: Check the Class filters checkbox to enable class filtering (as mentioned by @Scott Barta). Then click the ... (elipsis) button to open the Class Filters dialog. 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.* (note: as per OP's question, leave this out to NOT break on Java libraries)
    • android.* (as above, leave out to just debug own app code)
    • Add any additional namespaces as necessary (e.g. 3rd party libraries)

Class Filters

  1. Press OK, then dismiss the Breakpoints dialog.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...