How do I fix my debugger from stopping my app as soon as it is connected in Android Studio?

194 views Asked by At

I run my app with the "play icon" Play Icon

Then I connect my Debugger enter image description here

Android studio will then give me the message: Connected to the target VM, address: 'localhost:8601', transport: 'socket'

My issue is that now my app is no longer running and even though the debugger is connected, I am unable to debug as the app is not running. enter image description here

2

There are 2 answers

0
Perraco On

Add the next line where you wish the debugger to pause, it will make your environment to wait until the debugger attaches:

 Debug.waitForDebugger();

Place a breakpoint after it at the point where you would like to start to debug. I emphasize, the breakpoint must be at any point "after" such instruction.

Logically, is assumed that you are executing a debug build variant, otherwise the debugger will never attach.

0
SlowLearnah On

This is normal behavior, if you hoover over the stop button enter image description here

it will say "stop 'Android Debugger (8600)' indicating that the debugger is on. enter image description here