257

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.

10
  • If you haven't already, you could try unchecking "Use Host GPU" in the AVD Config for your emulator. Commented Dec 12, 2014 at 3:42
  • 2
    @JosephWebber Thanks for the suggestion, but I'm debugging on an actual hardware though Commented Dec 12, 2014 at 4:02
  • are you using a custom mod or stock one? Commented Feb 9, 2015 at 21:24
  • 1
    I tested on Nexus 7 2013 with stock Android 4.4.2, and Samsung S3 with Android 4.3, neither worked. Commented Feb 10, 2015 at 1:05
  • Hi, I got similar issue, I have try solution here but not work. Please help answer my question: stackoverflow.com/q/40838494/5241603 Commented Nov 29, 2016 at 3:14

45 Answers 45

305

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?

Sign up to request clarification or add additional context in comments.

4 Comments

where this command should be used? in the terminal?
@AndreaBuzzelli Yes, in your terminal
Thanks man. Just ran this in Terminal in AS and it cleared it up for me.
"adb shell am clear-debug-app" worked fine for me for virtual machine.
113

Restarting Testing device fix the issue for me.

5 Comments

Same here, I tried everything above and this one did it for me.. Sigh
Same here. My device was showing the message even when not connected to dev machine (not connected over adb in any way). So all the advice regarding Android Studio and ADB were irrelevant. TurningUSB debugging off/on didn't help either Rebooting the device was the only way to fix it.
Me device (emulated) was showing that message any time I opened the app (through Android Studio, or just from the launcher). Tried a whole bunch of stuff. Full on rebooting the phone didn't occur to me because it's been closed several times (but with a saved state, duh). This did the trick!
yes, holy restart helped for me too.
While this work. It is not a good solution. This problem keeps coming up every now and then.
113

On some machines/projects the debugger do not attach automatically so you need to attach it manually (studio menu -> Run -> Attach debugger to Android process)

4 Comments

Mine seemed to connect to the app before it was completely launched and "waiting for debugger", telling it to connect a second time after it was already connected resolved that. (android studio 162)
I was just in the Release mode :D
This work, when I try to run instrumented test in a virtual android, I get test to run. But it does not solve problem, that i have set test ti be to run. It is debugged!
so how to make it attach automatically??
63

Restarting Android Studio fix the issue for me.

4 Comments

Funny thing is that is the usual fix for Xcode problems. Apparently both platforms are not that different at the end :)
No. Not for me.
Sorry to hear that. Apparently 2 years later, there is another problem & (hopefully) solution :)
worked on AS 2023
37

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

9 Comments

what if i am not launching debug, bug just running the app
Exactly lxknvlk, here it is 2021 using android studio 4.2.2 and this major pain keeps showing up. Funny thing is it just all of a sudden starts doing this and NONE of the solutions does anything to fix it. I am using Nexus 5X API 28x86 and now I've wasted hours already trying to fix it. Restarted everything including rebooting the computer.
what if there are no processes listed?
@jave.web it is the solution for waiting state for the process.
@RohitKumar I know but I only see devices in the attach debugger, but no processes to select :/
|
25

A similar question has been asked recently and the solution may work for some and is very quick.

Clearing the Intellij IDEA (Android Studio) .idea directory which contains configuration information worked for me:

  1. Exit Android Studio
  2. Navigate to the project you are trying to debug
  3. Backup any files inside .idea that you modified (if your project checks any of these into VCS)
  4. Delete .idea directory
  5. Open the project in Android Studio

5 Comments

This solved the problem. Suddenly I couldn't debug on real hardware or the emulator. Rebooting everything didn't work. I could get by using Run -> Attach debugger to Android process, but it gets annoying after a while. It started happening after upgrading gradle, as the IDE suggested.
FYI ticket in google issue tracker: issuetracker.google.com/issues/37117600
standard answer to all android studio issues, reboot :). windws os in the making..
Didn't help. The message persists.
Thank you vman! I was sweating bullets. Not being able to debug is a disaster for me and this solved it.
24

Debugger stopped connecting for me today and nothing worked until I tried the following:

Go to Run, Edit-Configurations, Miscellaneous Tab, uncheck 'skip installation if APK has not changed' Apply, OK.

Debugger started to connect again.

2 Comments

Fudge, this worked for me when other answers did not work (restarting, deleting ".idea", etc). This answer is more than 5-years old and I am using the latest version of AS at the end of 2021. Why haven't Google fixed this issue? Even if they could not figured out the root cause, they could have easily make AS ignore that setting and install the APK if debugging keeps failing (unresponsive) for a certain amount of time....
For me it was checking "Automatically attach on Debug.waitForDebugger()" in the "Debugger" tab. After Settings | Developer Options | Debugging and "Select debug app" and "Wait for debugger" on the device. At least I'm getting back into the debugger when the app restarts after a low memory shutdown now.
23

This problem occurs when you open more than one instance of Android studio, so you need to attach the debugger manually like mentioned above.

You may need to close other instances of Android studio.

3 Comments

One thing to add: Maybe your have to restart android studio after closing the open instanc(es)... This helped me!
Another improvement - it does happen if you have just another IntelliJ IDEA open. Not need to be android studio
Android Studio was unable to start debugging in an Android Emulator, and closing IntelliJ solved the problem. The project opened in IntelliJ was not even an Android project (but just a console Kotlin project). Maybe it is because the Android component is installed in IntelliJ.
17

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

Comments

13

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

Comments

12

Both of my dev machines have JDK 8 installed, the debugging function is restored once JDK 7.0.71 was installed and JAVA_HOME environmental variable was set to point to the new JDK.

Guess there's some compatibility issue between Android Studio + ADB + JDK8 (Eclipse + ADB + JDK8 works fine).

7 Comments

I have the same problem, very annoying since requires phone reboot. Using JDK 1.7.0b147
JDK 8 is not officially supported by Android Studio - I have had problems compiling projects and they were resolved by going back to JDK 7.
where to change the version of JDK8 to JDK7 in latest version of Android Studio
@AnandKrish you have to change the default JDK/JRE of the computing environment, basically when you execute javac -version, the result should be javac 1.7.xxx. On the other hand, I'm using JDK 8 (1.8.0_60) on OSX and the aforementioned issue doesn't seem to exist anymore.
Correct! My machine have JDK 7 and JDK 8 installed. I have resolved this issue by change JDK location (Android Studio 2.1.1: File - Project Structure - SDK Location - JDK location) from JDK 8 to JDK 7.
|
8

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

Comments

8

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

Comments

7

This solution works for me:

turning off the USB debugging from my device settings , and then turning it on again.

its Much quicker and easier than restart the device.

1 Comment

worked for me too.
7

When the Device displays the message go to Run->Attach debbuger, then select a debbuger. it'll start the activity.

2 Comments

Too annoying. This just started happening today after YEARS of successful debugging with no problems.
I solved it by factory restoring my device. I need to get rid of it the as soon as possible.
7

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

1 Comment

Only answer that worked for me. Probably the right answer for people facing our version of the issue.
6

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

4 Comments

I also got the same issue with 'Persian' regional format. I faced this issue in newer version of android studio i.e. Android Studio Electric Eel | 2022.1.1 Patch 2 while I had no problem with Android Studio 3.5.3 2019 on the same machine and same configuration.
@VSB Did this answer solve your issue?
Yes, it fixed lots of problems. The app still waits for the debugger, but the situation is now much better after this change.
I also got the same issue with 'Persian' regional format with Android Studio Flamingo | 2022.2.1 Patch 2. It was Weird but I spent 8 hours to found this solution. Thank You ☺
4

How it worked for me.

1 Start Android Device Monitor from Tools -> Android -> Android Device Monitor

2 Click on Stop for the process you are facing the issue from list of devices.

Comments

4

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.

1 Comment

It's perfect solution
3

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

press enter

and again adb start-server

press enter

Comments

3

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".

1 Comment

This is also true when running IntelliJ Idea. You can't even attach the debugger.
3

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.

Comments

3

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

Comments

2

I had the same problem. Restart my android device and closed the adb.exe process. With that I could solve the problem

Comments

2

Most of the times this is caused because of the overload of resources and threads over the emulator. Or even for the lock of objects that GC couldn't set free: http://developer.android.com/intl/pt-br/tools/debugging/index.html

Usually, a single restart of it will solve the issue, but sometimes it asks for the IDE restart, so be sure to make both tests.

Another good test is trying to start the app in "Start mode" and then try the debug mode again...

P.S: Don't forget to kill each debug process in the IDE after each test. This will prevent your env to be more overloaded.

Comments

2

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

1 Comment

Thank you, this is the only thing that fixed my issue, which started happening after including exoplayer locally in my project.
2

Android studio 3.0 and Above

Disable the instant Run

enter image description here

1 Comment

With Android Studio 3.5.x, this option becomes HotSwap.
2

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

1 Comment

next time, try getting a new laptop, it works even better
2

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.

1 Comment

Thanks, fixed my issue. I had two android studio opened at the time.
2
  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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.