Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoints not Working in Android Studio 3.3

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?

like image 961
user982687 Avatar asked Jan 23 '19 00:01

user982687


People also ask

Why does the breakpoint set in Android Studio not stop running?

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.

What happens if you run a breakpoint on a release build?

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.

How do I stop a breakpoint from running in the background?

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.

How to debug a process in Android?

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.


2 Answers

Rebuild solved my problem.

clean & rebuild

Invalidates caches/restart if necessary

like image 26
user2301281 Avatar answered Sep 28 '22 01:09

user2301281


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!

like image 161
Khdkls Avatar answered Sep 28 '22 00:09

Khdkls