After noticing that some breakpoints are not getting hit, I found this post that answers why:
Breakpoints not working on Android Studio 3.3
I don't recall this happening prior to Android Studio 3.3. Is there any way to stop this behavior so that breakpoints will get hit on conditional statements?
There’s no indication in Android Studio this breakpoint set will not stop. This is regardless if you have set it to All thread or not. In Android, our app normally runs on the main process, regardless of the main thread or background thread.
Technically, even if you run it on release build, it will still stop and break on your breakpoint. You might not able to watch the variable value or evaluate any expression properly. This is because by default the release variant is set to minify enabled, and proguarded (code if obfuscated). Check out this StackOverflow 5.
Hence when you put a breakpoint on the code that is run on the background, it will not stop. To ensure your breakpoint stop in all thread, go to your breakpoint setting (right-click on the breakpoint), set it to All instead of Thread as shown below. Check out this StackOverflow.
The problem is solved by upgrading Android Studio from 3.6.2 to 4.0.0 it works for android 4.0.1. there is a button "attach debugger to android process" on top menu bar. click it and select the process. then the debugger will hit the break point.
Rebuild solved my problem.
clean & rebuild
Invalidates caches/restart if necessary
Found here setting minifyEnabled false in the debug build is the best practice.
I just change minifyEnabled in build.grandle to 'false' on debug buildTypes and it works!
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