Android Studio "Waiting for debugger" hangs, only on certain project - android

I have a big project in Android Studio, that recently started doing this problem when I try to debug it. I clean the project, rebuild it, no errors at all, then I debug it, and on the phone in stands forever on
Waiting for Debugger
This happens only on the project I am working on, if I make a new project and try to debug it, it runs without a problem, but on the previous one, it always hangs there and never finishes.
Also, if I try to run the project normally, it's ok, it runs, and then I open Tools -> Android -> Android Device Monitor, and from there the option to attach a debugger to the process is grey, I can't click it. Why is that? Could it be related to the main problem I am having?
EDIT: Restarting Studo, PC or device not helping
EDIT 2: Deleting the .gradle and .AndroidStudioXXX folders in user folder in Documents seems to have fixed the issue, but it also completely resetted Android Studio, so this is not a proper solution.

Once Invalidate Caches / restart your project. Keep that app is not available in your device.

Related

Can't debug Android app, gets stuck before I can hit any breakpoints

Trying to debug and it gets stuck here. Exception: Can't find resource for bundle android.icu.impl.ICUResourceBundleImpl$ResourceTable, key en_US
I am able to run the app fine on the emulator and physical device but when I try debugging it gets stuck here and doesn't reach my breakpoint. Was working fine and now this started happening all of the sudden.
I've tried Invalidate Caches/Restart, cleaning & rebuilding project, restarting my device and my PC, checking out a different branch, even did an Android Studio update and still getting this issue.
After 2 hours I realized the problem was that I had "Java Exception Breakpoints" and/or "Exception Breakpoints" checked on the Breakpoints settings. Unchecked them and everything is back to normal.

Android app does not get updated using Android Studio (2.1.1)

When I hit run, Android Studio installs the app on my device (not emulator), but sometimes the code does not change (e.g. some Logs still output to the console whilw they actually got removed).
I faced a similar problem before: When I tried to install the app, Android Studio said there were no changes made, so it canceled the process. I could solve this problem by unchecking "Skip installation if APK has not changed" in "Installation Options". (I disabled "Instant Run" as well).
Since Android Studio now returns "Success" when I run the app, I thought the problem was my device, so I restarted it, but nothing changed. Then I cleaned the caches of Android Studio, restarted AS, installed the app and it worked...
Because I don't want to clean my cache and restart Android Studio every hour, I look for a solution on this problem. Any suggestions?
This happens occasionally for me, and the best solution I've found is uninstalling the app from my phone and reinstalling it. To uninstall the app, hold down on the icon in the app list menu and drag it to the uninstall field. It should always reinstall with the updated code.

Android Studio hangs / Freezes when project build fails

I am experiencing a very wired problem since this evening.
If I have any errors in my android project, and build is failed, then my Android studio gets frozen / stuck. I cant do anything but kill the Android studio application.
Even if I open the same project next time, gradle will try to build and freezes again. [Please find attached screen shot]
Only solution I could find is .... I have to find what exactly cause the "build fail" and I will have to resolve the issue using some other editor, and then my android studio will start working.
Thing is it was working without any issues till this evening; and suddenly broken down. Any one else having the same issue ??
-n
If you are using Android Studio v1.2.1.1 or newer and you are using Macbook, I've recently seen that if your device is connected to your laptop (by usb have no idea about over the wifi) and you sleep your laptop then login again, Android Studio hang. Therefore, you need to unplug usb cable then you should see Android studio is happy and then reconnect your usb cable.
Open your terminal and reset adb:
adb kill-server
adb start-server
This is how I solved the same problem:
Go to your project directory using your terminal
run ./gradlew (or gradlew.bat) assembleDebug
Fix the problems reported by gradle
Restart android studio and the problem is gone
Based on barbarian's answer I did this on my Mac:
start a terminal
chmod +x gradlew
./gradlew
./gradlew build
This last step showed an error in my xml file, indicating that I used unescaped single quotes. Fixing that solved the hangup.
Well, I uninstalled android studio and installed it again, and now the problem has gone away.
I still wonder how in the world it broke in the first place.
In case some one else is facing the same issue, try reinstalling your studio.
In case if you are using Mac osx refer How to completely uninstall Android Studio? to uninstall Android studio properly; Because only deleting App will not completely uninstall it.
In my case the same thing happened, after I had added image-resources with dashes in the filename.
I manually deleted them, renamed them, and added them with underscores in the name, and Android Studio worked normally again.
(I am not sure the dashes were the reason, why should they, but doing the above fixed it.)
#Hesam's answer doesn't work for me. Using OSX and AS 1.2.1.1, my building stuck in 'Scanning files to index' and I cannot solve it even after restarted my Macbook. Below work for me:
Shut down Android Studio (force to kill or just unplug the usb you will be good to go)
Go to the directory of AndroidStudioProjects and move the application directory out to some other location (outside AndroidStudioProjects).
Restart the android studio, now you will be shown the screen asking you whether you want to start a new project or open an old one.
Again paste the folder you have cut and kept aside in step 2 back to AndroidStudioProjects directory.
In the android studio prompt, select open existing project and select the directory you have now just pasted to AndroidStudioProjects.
It should work for my case.

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
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.
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?
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)
Restarting Testing device fix the issue for me.
Restarting Android Studio fix the issue for me.
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
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.
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:
Exit Android Studio
Navigate to the project you are trying to debug
Backup any files inside .idea that you modified (if your project checks any of these into VCS)
Delete .idea directory
Open the project in Android Studio
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.
I faced this problem in android studio 3.0. Just restarted device solved.
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).
I tried the top three rated answers but failed. After rebooting my mobile, the problem is solved. No more long "Waiting for Debugger".
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.
When the Device displays the message go to Run->Attach debbuger, then select a debbuger. it'll start the activity.
This fixed it for me. Android Studio -> File -> Invalidate Caches & Restart...
I had the same problem. Restart my android phone device worked for me.
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.
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.
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:
Go to Start -> type Region -> click on Region to open Region window -> from the Format dropdown, select English (United Stated) -> Click OK.
Restart Android Studio.
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".
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.
Android studio 3.0 and Above
Disable the instant Run
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:
Root of Developer Options
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.
I had the same problem. Restart my android device and closed the adb.exe process. With that I could solve the problem
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:
Open Run/Debug configurations and within "Android app" pick the configuration you're using to debug your app.
Locate "Launch Options/Launch" there and set it to "Specified Activity" instead of "Default Activity".
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.
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
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.
Make sure that your Active Build Variant is debug.
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*/
}
}
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.
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.

Apk only runs in debug mode. Apk started with "Run" in Eclipse stops on breakpoints

I note that this has been asked before but I haven't found an answer yet. The main tell tale of this problem is that Eclipse stops on break points when the apk has been deployed as "Run"
I've done these so far and none produce a correctly running "Run" build from Project shell -> Run As -> 1. Android Application
• Disconnecting, uninstalling and re installing the apk does not fix the problem (this is a tablet device, not an emulator.)
• Made all of the project and library projects write able using the file system
• Brand new projects work correctly e.g. they don't stop on breakpoints in "Run" mode in the same Eclipse workspace as the problem project
• Window -> Preferences -> Run/Debug(expand) -> Launching "Launch in debug mode when workspace contains breakpoints" is set to never
• Closed and opened Eclipse
• Killed all of the running processes under the "Debug" tab in that perspective
• Cleaned the entire workspace both in Eclipse IDE and manually by deleting the res and gen folders of the main and library project dependencies
• Checked for the occurrence of the word "debug" in the project build files
• Clean built the project from the command line using: ant clean then ant release
Interestingly enough, when I clean build from the command line then fresh-install the new apk, if Eclipse is open the debugger will attach to the running process and stop at the first break point! If Eclipse is closed, the program will wait for the debugger with the standard "Waiting for Debugger" dialog.
So something is broken in the build process (haven't figured out what all files are getting involved yet) and/or something in .metadata and/or some depenency.
edit
I've found a file at:
C:\Projects\Mobile\Android\.metadata\.plugins\org.eclipse.debug.core\.launches\MyProjectName.launch
in the xml:
<launchConfiguration type="com.android.ide.eclipse.adt.debug.LaunchConfigType">
Don't know if it's a clue, but if I delete the file Eclipse will just replace it with the same.
edit
*Confirmed that the project Runs correctly when built and run from another machine, so I suspect that it's my work machine's Eclipse workspace that's causing this issue. Maybe I need to throw out all of the workspace's metadata and start over.
I encountered same issue. The solution is, restarting your device. Good luck.
You said you have breakpoints?
Try:
Window -> Preferences -> Run/Debug(expand) -> Launching
There should be a section entitled "Launch in debug mode when workspace contains breakpoints"
If that is not on "Never" that would be your problem.
I have the same problem and I need 4 steps to resolve them:
Disconnect the device
Reboot the device
Clean and build all the projects in workspace.
Start the app in emulator in Run mode and check it's ok.
Start the app in the device in Run mode and all works ok.
Only restarting the device not works for me!
I've encountered same problem: I could run my application only in debug mode, but it won't properly start when I press 'run' button. I've tried all solution here, but nothing works for me.
After some time I've found android.os.Debug.waitForDebugger(); in the begining of my Activity. I hope this answer sometimes help someone, because this question was first in Google, when I search for help.
Update
Use Intellij instead of Eclipse for Android development (far fewer IDE interface bugs) and then disregard the following altogether:
Two important rules I've found since the original post:
1) Get in the habit of waiting until Eclipse is finished build the workspace - the indicator shows up in the bottom left corner of Eclipse by default. WS build times can take minutes in a large project with multiple libs. Don't change anything until the build is complete.
2) Close all projects in the workspace and reopen them one-at-a-time starting with the project with no lib dependencies and so on. Make sure not to open a project until you can verify the the workspace has finished building what is already open. Fix any issues along the way before opening the next project.
Good luck.
Happens to me sometimes - have you uninstalled the application completely from the handset and tried to reinstall? Can you install the apk and then disconnect the handset from the machine? (obv won't work if you're using an emulator)
Faced same issue on Samsung S4 and issue is fixed by unchecking "Wait for debugger" option under "Developer options".
Had the same issue, check that you haven't got this line of code anywhere in your project:
android.os.Debug.waitForDebugger();
It may exist in a Service for debugging purposes, once you comment it out it will work in release mode. The problem is that this line of code waits for the debugger, and if you're not running in debug mode it will wait indefinitely

Categories

Resources