236

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.

Kai
  • 15,284
  • 6
  • 51
  • 82
  • If you haven't already, you could try unchecking "Use Host GPU" in the AVD Config for your emulator. – Joseph Webber Dec 12 '14 at 03:42
  • 2
    @JosephWebber Thanks for the suggestion, but I'm debugging on an actual hardware though – Kai Dec 12 '14 at 04:02
  • are you using a custom mod or stock one? – Shine Feb 09 '15 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. – Kai Feb 10 '15 at 01:05
  • Hi, I got similar issue, I have try solution here but not work. Please help answer my question: http://stackoverflow.com/q/40838494/5241603 – K.Sopheak Nov 29 '16 at 03:14
  • Possible duplicate of [Why Android Studio says "Waiting For Debugger" if am NOT debugging?](http://stackoverflow.com/questions/20537845/why-android-studio-says-waiting-for-debugger-if-am-not-debugging) – AlikElzin-kilaka Dec 13 '16 at 06:31
  • @Kai I took a look again at both questions, they still look the same to me, yours has more logs/images. The solution I mention in what I believe is a duplicate, has helped multiple people with the issue you have described on AOSP Issue tracker. Can you explain how yours is a different issue? This is my first time marking something as a duplicate, I probably should have marked the other question as a duplicate instead. – vman Jan 19 '17 at 08:43
  • @Kai Removing the duplicate flag and will link my answer here since the same question you asked might be solved using a quicker method for some people. – vman Jan 19 '17 at 19:04
  • in my case i have to uncheck Wait for debugger in device Settings. – Beeing Jk Oct 12 '17 at 02:12
  • Nothing helped me of all the solutions. This problem is already years old. Its a shame that the developers of Androidstudio doesn't care about this. So many hours lost with hacking around to get into the debug mode. – mcfly soft Mar 05 '22 at 07:26

40 Answers40

264

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?

Top-Master
  • 7,611
  • 5
  • 39
  • 71
twlkyao
  • 14,302
  • 7
  • 27
  • 44
110

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)

Ohad Cohen
  • 5,756
  • 3
  • 39
  • 36
108

Restarting Testing device fix the issue for me.

Nisar Ahmad
  • 1,987
  • 3
  • 13
  • 30
  • Same here, I tried everything above and this one did it for me.. Sigh – Dayan Nov 21 '16 at 20:21
  • 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. – Mark Oct 10 '17 at 15:06
  • 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! – Nieminen Apr 10 '20 at 01:14
  • yes, holy restart helped for me too. – danyapd Nov 12 '21 at 01:01
  • While this work. It is not a good solution. This problem keeps coming up every now and then. – TheRealChx101 Mar 28 '23 at 13:52
63

Restarting Android Studio fix the issue for me.

hris.to
  • 6,235
  • 3
  • 46
  • 55
35

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

Rohit Kumar
  • 728
  • 9
  • 13
  • 6
    what if i am not launching debug, bug just running the app – lxknvlk Jun 27 '20 at 07:46
  • 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. – mikeB Jul 21 '21 at 01:53
  • what if there are no processes listed? – jave.web May 21 '22 at 18:34
  • @jave.web it is the solution for waiting state for the process. – Rohit Kumar May 22 '22 at 11:19
  • @RohitKumar I know but I only see devices in the attach debugger, but no processes to select :/ – jave.web May 22 '22 at 19:44
  • @jave.web then the app is still waiting for the device to install, this is after that – Rohit Kumar May 23 '22 at 17:03
  • @RohitKumar nope the app is already installed :/ this after it's installed and opens, then there's a splash screen and then nothing - the nothing I would like to debug, but it stops on the waiting on the splash screen :/ – jave.web May 23 '22 at 19:25
  • @jave.web check your logcat, if there is a process attached, it means you can attach debugger to that process – Rohit Kumar May 24 '22 at 17:08
24

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
Community
  • 1
  • 1
vman
  • 1,264
  • 11
  • 20
  • 7
    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. – ASalazar Mar 07 '17 at 00:13
  • 1
    FYI ticket in google issue tracker: https://issuetracker.google.com/issues/37117600 – vman Apr 20 '17 at 17:54
  • standard answer to all android studio issues, reboot :). windws os in the making.. – Siddharth May 14 '18 at 12:30
  • Didn't help. The message persists. – Mitch Sep 10 '19 at 23:28
  • Thank you vman! I was sweating bullets. Not being able to debug is a disaster for me and this solved it. – pigdog627 Sep 05 '21 at 19:50
23

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.

user2658370
  • 259
  • 2
  • 4
  • 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.... – Damn Vegetables Dec 28 '21 at 02:09
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.

Prasanna Narshim
  • 778
  • 10
  • 14
  • 1
    One thing to add: Maybe your have to restart android studio after closing the open instanc(es)... This helped me! – JonasPTFL Oct 18 '19 at 18:14
  • Another improvement - it does happen if you have just another IntelliJ IDEA open. Not need to be android studio – Konstantin Pribluda Dec 29 '20 at 14:51
  • 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. – Damn Vegetables Dec 28 '21 at 15:06
16

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

John Ruban Singh
  • 1,284
  • 14
  • 19
13

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

Jeff T.
  • 2,193
  • 27
  • 32
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).

Kai
  • 15,284
  • 6
  • 51
  • 82
  • 3
    I have the same problem, very annoying since requires phone reboot. Using JDK 1.7.0b147 – Shine Feb 09 '15 at 21:25
  • 3
    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. – ekchang Feb 13 '15 at 00:15
  • where to change the version of JDK8 to JDK7 in latest version of Android Studio – anand krish Jan 28 '16 at 09:37
  • 1
    @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. – Kai Jan 28 '16 at 10:13
  • 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. – valerybodak May 25 '16 at 12:13
  • Just a note - the current version of Android Studio, 2.2.3, indicates that JDK 8 is required, so this is no longer the correct answer for those on the latest version. – nasch Feb 21 '17 at 03:42
  • I switched back to the embedded version (recommended) thru Project structure as suggested above - and that fixed the issue hanging on "collecting data". Thanks – Robert de W Feb 27 '17 at 21:48
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

Foenix
  • 376
  • 4
  • 18
7

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

Billy
  • 437
  • 1
  • 6
  • 13
6

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

Eduardo Boada
  • 91
  • 2
  • 8
6

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

Ram Chhabra
  • 421
  • 8
  • 11
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

  • 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 Apr 06 '23 at 11:43
  • @VSB Did this answer solve your issue? – Ali Hussein Al-Issa Apr 07 '23 at 13:21
  • 1
    Yes, it fixed lots of problems. The app still waits for the debugger, but the situation is now much better after this change. – VSB Apr 09 '23 at 13:02
  • 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 ☺ – AliReza Jul 19 '23 at 01:13
4

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.

Fasiha
  • 488
  • 3
  • 11
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.

RAHUL JOSHI
  • 344
  • 1
  • 5
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.

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

solamour
  • 2,764
  • 22
  • 22
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.

diogo
  • 3,769
  • 1
  • 24
  • 30
2

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

press enter

and again adb start-server

press enter

kudzai zishumba
  • 652
  • 2
  • 7
  • 12
2

Android studio 3.0 and Above

Disable the instant Run

enter image description here

Vicky
  • 5,098
  • 2
  • 33
  • 31
2

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

disha4mourya
  • 369
  • 4
  • 7
1

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

Xinoon
  • 85
  • 1
  • 3
1

Well, I guess there is a plethora of circumstances that can trigger this issue. I'm using IntelliJ Idea instead, but it's mostly the same than Android Studio. My solution for this problem:

Fastest way:

Right click on the class file that contains the main activity of your project, and then on "Debug 'WhateverActivity'". This will create a new run configuration that should debug fine.

Other solution, without creating a new run configuration:

  1. Open Run/Debug configurations and within "Android app" pick the configuration you're using to debug your app.
  2. Locate "Launch Options/Launch" there and set it to "Specified Activity" instead of "Default Activity".
  3. In the "Launch" field just below the aforementioned option, click on the three ellipsis (three dots) button and select your main activity.

At least it worked for me. I hope it works for others too.

Fran Marzoa
  • 4,293
  • 1
  • 37
  • 53
  • As a side note, beware with USB hubs and low quality USB cables. I've experienced this sort of problem due these too. – Fran Marzoa Sep 14 '17 at 17:25
1

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

Alexey
  • 440
  • 3
  • 12
  • 1
    Thank you, this is the only thing that fixed my issue, which started happening after including exoplayer locally in my project. – almiki Mar 31 '21 at 17:09
1

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.

Juan Saravia
  • 7,661
  • 6
  • 29
  • 41
1

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*/
        }
    }
Gk Mohammad Emon
  • 6,084
  • 3
  • 42
  • 42
1

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

1

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.

codemonkey
  • 1,213
  • 2
  • 14
  • 31
0

Restarting everything didn't work for me. What DID work was waiting for a few minutes while Android Studio unclogged itself. This was the first time I ran the debugger; after that, Android Studio fired up the debugger quickly.

Yusuf X
  • 14,513
  • 5
  • 35
  • 47
0

For me Run->Attach debugger to Android process was working, but I had to do it every time app was launched.

Fix: There may be a problem with your 'App launch configuration'(To verify this create new project to see if it's working fine). Just delete app configuration, open MainActivity file and Run->Debug (new conffiguration will be created)

Igor
  • 2,039
  • 23
  • 27
0

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

Gianluigi Liguori
  • 351
  • 1
  • 5
  • 13
0

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

from56
  • 3,976
  • 2
  • 13
  • 23
0

For my case, I have to reinstall the AVD.

0

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.

Mohsen Hrt
  • 263
  • 2
  • 9
0

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.

John Hassell
  • 19
  • 2
  • 5
0

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.

DotCFile
  • 59
  • 1
  • 4
-3

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

Pnemonic
  • 1,685
  • 17
  • 17