Kai
Kai

Reputation: 15476

Debugging with Android Studio stuck at "Waiting For Debugger" forever

UPDATE The supposed duplicate is a question on being stucking in "Waiting For Debugger" when executing Run, while this question is on being stucking in "Waiting For Debugger" when executing Debug, the steps to produce the problem is different, and the solution(s) are different as well.


Whenever I try to use Android Studio's Debug function, the Run status would always stuck at:

Launching application: com.astrotek.parashoot.debug/com.astrotek.ptpviewer.StarterActivity.
DEVICE SHELL COMMAND: am start -n "com.astrotek.parashoot.debug/com.astrotek.ptpviewer.StarterActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.astrotek.parashoot.debug/com.astrotek.ptpviewer.StarterActivity }

While the device (Samsung Galaxy S3 Android 4.3) I'm debugging would display

enter image description here

This has being the case from Android Studio 0.8.8 all the way to 1.0. And on the same computer I can perform debugging using Eclipse on the same device without any issues.

So the question is what can I do to make Android Studio debugging work?


Update: The same thing happens when debugging on Nexus 7 (2013) running Android 5.0; and testing on another machine rendered the same result. I can't be the only one encountering this issue :-/


Update: Opened a bounty since this issue is so annoying. Even re-installing the app doesn't solve. Nexus 5 running Cyano, Win7 64. The ADB log is telling:

8568-8568/it.myapp:myprocess W/ActivityThread﹕ Application it.myapp is waiting for the debugger on port 8100...
8568-8568/it.myapp:myprocess I/System.out﹕ Sending WAIT chunk

Also, I can't find an easy way to disconnect nor reset ADB connection in Android Studio.

Upvotes: 253

Views: 186955

Answers (30)

Jože Ws
Jože Ws

Reputation: 1814

Solution for Android apps with C++ code (native code)

I have an Android app that has some C++ code and it seems that this puts a big load on the device - therefore timing out the debug connection. I solved it by using the Java Only debug mode.

  • Select your configuration on the top toolbar
  • Select Edit Configurations...
  • Select the Debugger Type tab
  • In the Debug Type menu select Java only.

enter image description here

Upvotes: 1

DavidG
DavidG

Reputation: 371

For MAUI: you'll get an indefinite hang waiting for debugger to attach if you have both visual studio and android studio open at the same time.

Upvotes: 0

blade
blade

Reputation: 843

In my case manually deleting the previously installed app(package) solved the issue: adb shell pm list packages adb uninstall com.something.myapp.test

Upvotes: 1

tushar agarwal
tushar agarwal

Reputation: 41

  1. Enable Developer Options: Ensure that Developer Options are enabled on your Android device. To enable Developer Options, go to Settings -> About Phone -> Tap on Build Number multiple times until you see a message confirming that Developer Options are enabled.

  2. Select Debug App:

In Developer Options, find and select the "Select debug app option". Choose the app that is causing the debugger attachment issues.

  1. Select "Nothing" Option:

When prompted to select the debugging app, choose the "Nothing" option.

Below are some screenshots :

Select Debug App option

Select Nothing

Upvotes: 2

skalber
skalber

Reputation: 519

Toggling airplane mode on the device fixed it for me (without doing a reset)

Upvotes: 0

DotCFile
DotCFile

Reputation: 119

Solution using the Terminal

Using @twlkyao answer I entered in the terminal:

adb shell am clear-debug-app

And the response was:

adb.exe: more than one device/emulator

Then, taking a hint from @kudzai zishumba answer, I entered:

adb kill-server

And that cured my problem. I'm surmising that the debugger was attached to the emulator and also to my phone. It's my phone I'm wanting to run debug on, not the emulator.

Upvotes: 3

codemonkey
codemonkey

Reputation: 1231

For me the problem was having IntelliJ open at the same time as Android Studio. I was using IntelliJ for back-end development at the same time as Android Studio for app development. Even though I was not doing any mobile device work with IntelliJ, it broke debugging in Android Studio.

Solution: Shutdown IntelliJ when debugging with Android Studio.

Upvotes: 2

mostafa toloo
mostafa toloo

Reputation: 61

Change your time zone and region format. unfortunately, some regions are restricted.

Upvotes: 1

twlkyao
twlkyao

Reputation: 14628

Obviously is yet another Android Studio, or rather ADB bug.

Just use this command to disable it. adb shell am clear-debug-app

OR

Ensure there is nothing to wait for, by automatic uninstall from Device before each test-run, using Gradle's uninstallAll task, as mentioned in:
stackoverflow.com/Auto uninstall before install?

Upvotes: 289

disha4mourya
disha4mourya

Reputation: 369

Tried all the solutions given here but restarting my laptop worked for me.

Upvotes: 2

Ali Hussein Al-Issa
Ali Hussein Al-Issa

Reputation: 685

For me, the issue was: The Regional Format of Windows was ARABIC. I simply changed the regional format to English (United States) and the error has fixed.

Steps to fix:

  1. Go to Start -> type Region -> click on Region to open Region window -> from the Format dropdown, select English (United Stated) -> Click OK.
  2. Restart Android Studio.

Region window

Upvotes: 6

John Hassell
John Hassell

Reputation: 19

In my Linux Ubuntu Android Studio development environment, entirely deleting my configuration folder, ~/.config/Google/AndroidStudio2021.1, and restarting Android Studio was the only way to restore native debugging ability.

Upvotes: 0

This also happens to me from time to time. Problem is that your app / device is configured to wait for debugger. In this case it is waiting for debugger before continuing execution of.

Option 1:

Attach debugger or run in debug mode. You can do this in Android Studio. Buttons to attach debugger and run in debug mode are located next to normal run mode (Bug and Bug with arrow).

Option 2:

Disable Wait for debugger. You can do this is developer settings. This option needs to be disabled in:
  1. Root of Developer Options
  2. Developer options -> Select debug app -> -> Wait for debugger

This was tested on Android emulator in android studio. Other phones might have this setting different. If you can not find app's settings in debug, reinstalling app might work too.

Upvotes: 4

Mohsen Hrt
Mohsen Hrt

Reputation: 303

Seems this is another Android Studio bug. To prevent this problem return back to Android Studio v4.1.3 (4.1.1) or earlier and use Android Gradle Plugin Version 4.1+ and Gradle Version 6.6 . After this, android studio works fine. Say if this answer is useful, Thanks.

Upvotes: 0

Rohit Kumar
Rohit Kumar

Reputation: 758

After clicking on the run icon. If it is stuck waiting for a debugger means it is not attached to the app. You have to manually attach by clicking on Attach Debugger to Android process. It is on the right side of the run icon. I had focus this icon in linked image.

Updated Image for Attach Debugger to Android process Icon

new Image for Attach Debugger icon

Upvotes: 36

mengjie warmuth
mengjie warmuth

Reputation: 15

For my case, I have to reinstall the AVD.

Upvotes: 0

Gk Mohammad Emon
Gk Mohammad Emon

Reputation: 6938

Make sure that your Active Build Variant is debug.

enter image description here

If you also want to make your release variant APK debuggable then make a simple change in app level build.gradle -

buildTypes {
        release {
            debuggable true
            /*Your rest code*/
        }
    }

Upvotes: 1

Ram Chhabra
Ram Chhabra

Reputation: 441

I had the same problem. Restart my android phone device worked for me.

Upvotes: 7

solamour
solamour

Reputation: 3194

As for my case, running Android Studio Canary (preview release) along with the stable version was the problem. Running multiple instances of the same Android Studio flavor was OK, but mixing them often resulted in "Waiting For Debugger".

Upvotes: 3

Pnemonic
Pnemonic

Reputation: 1825

If all else fails, try "Clean Storage" via the app's System Settings.

Upvotes: -3

Vicky
Vicky

Reputation: 5136

Android studio 3.0 and Above

Disable the instant Run

enter image description here

Upvotes: 2

from56
from56

Reputation: 4127

It has happened to me that it stayed stuck in "Waiting for Debugger" when accidentally I tried to Debug a Release build, sometimes it warns that it is not a debug build and others it silently stucks in "Waiting for Debugger".

The solution is obviously to switch to Debug build

Upvotes: 0

John Ruban Singh
John Ruban Singh

Reputation: 1326

I faced this problem in android studio 3.0. Just restarted device solved.

Upvotes: 17

Jeff T.
Jeff T.

Reputation: 2271

I tried the top three rated answers but failed. After rebooting my mobile, the problem is solved. No more long "Waiting for Debugger".

Upvotes: 13

Foenix
Foenix

Reputation: 538

I just managed this problem, after several days of trying the above solutions. So I closed the emulator, run AVD manager and in device menu choose - "wipe data" So in next run I was free from stucked debugger. AVD manager

Upvotes: 8

Juan Saravia
Juan Saravia

Reputation: 7711

Non of this solutions worked for me.

In my case was that I was debugging an App from Intellij IDEA and at the same time with Android Studio. By just closing the Intellij IDEA and removing the app I was debugging just fixed my problem.

Upvotes: 1

Gianluigi Liguori
Gianluigi Liguori

Reputation: 361

Sometime it's due to the fact that in the build.gradle configuration you have to set the node:

  debug {
            debuggable true
        }

Change it back to false when you have to prepare the signed apk.

Regards

Upvotes: 0

kudzai zishumba
kudzai zishumba

Reputation: 732

Open Command prompt and go to android sdk>platform-tools> adb kill-server

press enter

and again adb start-server

press enter

Upvotes: 2

Alexey
Alexey

Reputation: 505

Got it fixed according this solution: https://youtrack.jetbrains.com/issue/IDEA-166153
I opened <project dir>/.idea/workspace.xml replaced all the
<option name="DEBUGGER_TYPE" value="Auto" /> occurrences to
<option name="DEBUGGER_TYPE" value="Java" />
and restarted Android Studio

Upvotes: 2

Billy
Billy

Reputation: 488

This fixed it for me. Android Studio -> File -> Invalidate Caches & Restart...

Upvotes: 8

Related Questions