[android] 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.

This question is related to android android-studio android-debug

The answer is


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)


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

Restarting Android Studio fix the issue for me.


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


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


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.


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.


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


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.


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.


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


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.


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


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


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


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.


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)


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

press enter

and again adb start-server

press enter


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.


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


After click on run icon. If it stuck at waiting for 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 run icon. I had focus this icon in linked image.


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.


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


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


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


Android studio 3.0 and Above

Disable the instant Run

enter image description here


Restarting Testing device fix the issue for me.


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


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


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to android-debug

'Source code does not match the bytecode' when debugging on a device How to debug in Android Studio using adb over WiFi Debugging with Android Studio stuck at "Waiting For Debugger" forever How to use Monitor (DDMS) tool to debug application What does it mean with bug report captured in android tablet? How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator"