Android Studio IDE:异常中断 [英] Android Studio IDE: Break on Exception

查看:237
本文介绍了Android Studio IDE:异常中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我的Android Studio默认情况下不想破坏任何异常。在任何异常中启用中断将在实际的JDE库中断开。有没有办法强制它仅在我的代码中的异常中断?



来自Visual Studio Universe,在这里查找默认的VS调试行为。 >

解决方案

打破所有异常,被捕获或未被捕获:


  1. 通过运行 - >查看断点打开断点窗口。

  2. 出现断点对话框。在左窗格中,滚动到底部。在 Java异常断点下选择任何异常

  3. 选择了任何异常,在右窗格中配置如下:


    • 暂停:已检查

    • 全部:选择

    • 条件:!(this instanceof java.lang.ClassNotFoundException)

    • 通知:捕获异常未捕获异常选择



  • 检查启用类过滤(,如@Scott Barta 所述)的类过滤器复选框。然后单击 ... (elipsis)按钮打开类过滤器对话框。通过点击(添加模式)按钮来指定类命名空间模式。输入:


    • com.myapp。* (将其替换为应用程序的命名空间前缀) / li>
    • java。* (注意:根据OP的问题,请不要破坏Java库)

    • android。* (如上所述,只是调试自己的应用程序代码)

    • 将任何其他命名空间添加为必要的(例如第三方库)



    1. 确定,然后关闭断点对话框。


    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.

    解决方案

    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

    1. 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) 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)

    1. Press OK, then dismiss the Breakpoints dialog.

    这篇关于Android Studio IDE:异常中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆