I have been trying for months to get my debugger to break on my own code, with no success. Every uncaught exception breaks in the ZygoteInit.run() method.
Here is a list of actions I've taken.
debug { debuggable true }
to my app module's build.gradle filedebuggable="true"
to my AndroidManifest.xml fileAny exception
checkbox in the Breakpoints windowAny exception
breakpoint
I have been debugging by looking at the stack trace in Logcat, which does show my classes in the stack trace.
I have seen this version on current & previous builds in the stable AND canary channels.
Is there something here I'm missing?
EDIT: Just to clarify for people, the issue was that I had the "Caught exception" box unchecked. Checking this box fixed my issue.
Here is the relevant part of my Gradle file, if it helps at all.
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"
}
}
Here is a screenshot of my Breakpoints window.
Show activity on this post. Press Alt + 6 to open the Android DDMS window or alternatively press CTRL + Shift + A and enter Android .
To add a line breakpoint, proceed as follows: Locate the line of code where you want to pause execution, then either click the left gutter along that line of code or place the caret on the line and press Control+F8 (on Mac, Command+F8).
Breakpoints are set with the break command (abbreviated b ). The debugger convenience variable `$bpnum' records the number of the breakpoint you've set most recently; see section Convenience variables, for a discussion of what you can do with convenience variables.
An exception breakpoint is a type of breakpoint that is created when some exception occurs in the code. On occurrence of such exception our application stops at that given condition causing the exception and we can access all variables in scope at that breakpoint.
A couple more things to ensure:
See more detailed instructions here: https://stackoverflow.com/a/28862538/3063884
This approach catches all exceptions that are raised (when 'caught' and 'uncaught' are checked). Thus all internal exceptions are raised. The specification of a class filter restricts this by excluding some of these exceptions. For example, in the screen-dump above, the ClassNotFoundException
, which is raised frequently during start-up, is ignored.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With