几个月来我一直在尝试让调试器打破我自己的代码,但没有成功。每个未捕获的异常都会在 ZygoteInit.run() 方法中中断。
这是我已采取的行动的列表。
- Added
debug { debuggable true }
到我的应用程序模块的 build.gradle 文件
- 手动添加
debuggable="true"
到我的 AndroidManifest.xml 文件
- 检查了
Any exception
断点窗口中的复选框
- Added relevant class filter patterns to the
Any exception
breakpoint
我一直在通过查看 Logcat 中的堆栈跟踪进行调试,它确实在堆栈跟踪中显示了我的类。
我在稳定频道和金丝雀频道中的当前和以前的版本中看到过这个版本。
我在这里缺少什么吗?
编辑:只是为了向人们澄清,问题是我未选中“捕获异常”框。选中此框解决了我的问题。
这是我的 Gradle 文件的相关部分(如果有帮助的话)。
android {
compileSdkVersion 22
buildToolsVersion '22.0.0'
defaultConfig {
applicationId "com.--redacted--"
minSdkVersion 15
targetSdkVersion 22
versionCode 30
versionName "0.0.30"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/beans.xml'
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
这是我的“断点”窗口的屏幕截图。
还有几件事需要确保:
- 暂停设置为全部
- Notifications on:
-
捕获异常是否要捕获已定义错误处理的异常
-
未捕获的异常如果要捕获未处理的异常
- 将类过滤器设置为仅包含您的代码、Android 代码和 Java 代码
请在此处查看更详细的说明:https://stackoverflow.com/a/28862538/3063884 https://stackoverflow.com/a/28862538/3063884
此方法捕获引发的所有异常(当检查“捕获”和“未捕获”时)。因此会引发所有内部异常。类过滤器的规范通过排除其中一些异常来限制这一点。例如,在上面的屏幕转储中,ClassNotFoundException
启动期间频繁引发的 被忽略。
A small downside of this approach is that during app start-up, there may be a message indicating "Cannot find source class for current stack frame". This is because not all of the source code has been loaded yet. This will only occur once during start-up and can safely be ignored. An alternative approach to avoid this (if there are no exceptions expected during app start-up) is to 'Run' the application (as opposed to starting 'Debug'), and then manually attach the app to the debugger via Run -> Attach debugger to Android process ... or by pressing the button in the toolbar.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)