Debug in Android Studio no longer working - android

I'm working in Android Studio, and have been happily running in normal mode and debug mode for ages. Suddenly, debug mode has stopped working for me.
If I try to click on the Debug button (the little bug with the 'play' triangle), it attempts to start in the emulator, but the app never opens.
On the emulator, I get the "Waiting for debugger" alert, and the option to "Force Close". On Android Studio itself, the debug window at the bottom repeatedly shows "Waiting for application to come online:", and then "Could not connect to remote process. Aborting debug session."
I can run it fine in normal mode. It makes no difference whether I use the debug button to start the emulator, or whether it's already open in normal mode and I use the debug button to switch to debug mode.
I've tried restarting everything, and it hasn't made any difference. Any solutions I can find online are for much older versions of Android Studio.
Any ideas what I can try? I'm working around it with lots of Logs, but that's really slow.

I seem to have resolved this by choosing the 'debug' flavour before opening the emulator. It makes sense to need to do that, but 1) it didn't work like that before and 2) if it's now required, it seems like there should be some kind of error message with more details. Hope this helps someone else, though!

I tried to kill adb.exe process and this problem resolved.
(How to restart ADB manually from Android Studio)

Related

Logcat in Android Studio Android Monitor only runs once

I am new to Android Studio (running the latest updated version) however I am trying to debug with Android monitor and Logcat only seems to work once then stops reporting!!!
This occurs for all my projects?!?
If i restart Logcat it just clears the messages.
I assume the emulator cannot connect to the debugger for some reason.
When I restart Android Studio logcat reports, but when I close the app running on the emulator it stops reporting.
This CANNOT be the default intentional behaviour, does this affect other people?
Many thanks for any help at all.
Simply restarting Android Studio is the best solution
By default if your close the emulator it unattaches itself from Android Studio, stops Android Monitor and logcat and doesn't reattach when starting again. If you stop it in android studio and run it again the emulator is still attached to Android monitor and logcat.
I assume the emulator cannot connect to the debugger for some reason. When I restart Android Studio logcat reports, but when I close the app running on the emulator it stops reporting. This CANNOT be the default intentional behaviour, does this affect other people? Many thanks for any help at all.
An answer to this part is that it does not sound like expected behavior of Android Studio / logcat / emulator. I am able to start and quit the app multiple times, each time logcat connects when the app begins and disconnects after. I can start the application through Android Studio or through the apps menu on the emulator. I can quit and restart the emulator.
An easy thing is double check the dropdowns along the top of the logcat display, especially the emulator, app, and filter selectors.
I once had an issue that sounded similar, with logcat not reconnecting. The issue there was my terminal and IDE were running different ADK installs and they were competing for the logcat connection. So what you describe is possible, but not the norm. Perhaps another debuggable app or connected device could cause similar confusion.

Application is waiting for the debugger to attach

I,m working in eclipse to develop an android app and when i tried to debugged on my samsung tab, i got the following msg on its screen "Waiting for debugger" and beneath it was written "application xxx is waiting for the debugger to attach ", I did some search and found to:
See target sdk
Restart eclipse and device
Update eclipse
Uninstall app from device and install again
I tried all this, but nothing helped. Kindly help me.
In my Nexus 7 Tablet running android 4.4.2
I solved this problem by going into
Settings
Developer options
Select Debug app
was selected , Select Nothing
Done!
Sometimes "force to close and open again" doesn´t work, so this problem could be present when the application is currently in debug and is selected to be debugged, then from your device go to:
Settings ->
Developer options ->
Select app to be debugged ->
Select Nothing
or when the application is supossed to being in "debug mode" but is not selected as be debugged :
Settings ->
Developer options ->
Select app to be debugged ->
Select the application!
I had same issue. Adding permission didn't help me, because Eclipse automatically enables debugging when it runs in debug mode.
Check your device setting whether "Wait for debugger" is unchecked under "Developer Options".
Also I tried closing and restarting Eclipse, and finally it worked!
I'm still figuring out what the real problem is, but hope this helps!
Restarting Eclipse is the only solution which works every time for me.
Go to Settings->Developer options.
And then just turn off and on check box right to the Developer options title.
Also toggle USB Debugging again.
Worked for me
I was having same problem with my emulator.
What i did is,
Close the emulator
Open AVD manager
Wipe Data from dropdown for the required emulator in AVD Manager. May be same thing work for devices also.
This has been asked before. It is uncommon, but some devices need an extra permission(flag) to let the debugger attach!
So open your androidManifest.xml and add this permission:
<uses-permission android:name="android.permission.SET_DEBUG_APP"></uses-permission>
Another reason for this dialog to hang there is when you have breakpoints in different processes of your components (application / activity etc...).
For example:
If you have a breakpoint in an activity that runs on a different process than your main application you will see this dialog until you attach the debugger to the process manually.
For android studio it will be using the icon in the middle:
The intuitive reason for this will be that when you run in a debug mode the debugger is attached to your main application process and not to all your other processes, thus you need to specify manually to which process you want to attach your debugger.
I had this problem when I press only F11 to Run.
Pressing F11 does debug. In order to run, press Ctrl+F11.
I haven't ever seen this problem after do like this.
I ran into this issue on Android Studio 2.0 with a Nexus 6 running 6.0.1.
I tried most of the suggestions above and finally fixed it by restarting both Android Studio and my Nexus 6.
I had this same issue and eventually found that in AndroidManifest.xml the Application element had the following attribute:
android:debuggable="false"
I changed this to
android:debuggable="true"
And the debugging then worked correctly.
I had the same problem with my Samsung S4 mini: after hibernating my pc with running eclipse, my phone couldn't connect with the debugger anymore. Restarting phone and eclipse didn't work.
I found, that my eclipse "disabled" the debugger in the android devices view: Window menu -> Show View -> Other -> Android -> Devices (also called DDMS view)
There was a red bug in front of my device. I enabled debugging by pushing the green bug button and now debugging works fine. This also works, if there is no bug in front of your debugging device.
It's also good to investigate port 8700 (the DDMS "base port", a port forwarder). When TCPView shows that this port is kept by process "", it's impossible to connect to ADB and debug. This process can't be killed nor terminated in TCPView. After logging out of Windows and logging in again, this port is free again. After starting AndroidStudio/IntelliJIdea this port is owned by process "idea64.exe" and its possible to debug.
When application crashes and AndroidStudio is restarted without stopping debugger (which also detaches from ADB), it may happen that port 8700 is not released, blocked by process "".
TCPView: https://technet.microsoft.com/en-us/library/bb897437.aspx
http://developer.android.com/tools/debugging/ddms.html
I got this error even when the USB was unplugged, and the app wouldn't start.
The only thing that worked for me was restarting the Android device.
I found this simple solution to it. Just click on the debug panel tab at the lower potion of your eclipse or wherever it is. Tada!! It works! It seems eclipse is getting old it needs a slight nudge. Works every time for me!
I got stuck with this when I tried to debug from IntelliJ cause I had both IntelliJ and Android Studio open.
Even if there where no debug-process going on in Android Studio, I was able to launch debug from IntelliJ after I closed Android Studio.
Restarted the Android Studio but that didn't help. Unplugged the device from USB and plugged it back in which did the trick for me, no changes needed in Developer options in the phone settings.
I have tried the following to no avail:
Restart the Android device.
Turn Developer options off/on under the Settings of the Android device.
Disable/enable USB debugging.
Restart Android Studio.
It started working after: Android Studio > File > Invalidate Caches/Restart...
For me it was when two different Android Studio were launched simultaneously
It's normal message when you debugging your application. Just wait for several seconds and app will start.
Simply force to close then, open it again :)
Edited:
force to close the application, and then go to menu and start the application by clicking on the apps icon

Eclipse connects to android debugger, but does not enter debug mode - what is wrong?

I'm failing to debug my Android app. I have set a breakpoint in the onCreate() method of an app, and starts the app in debug mode from Eclipse. The debugger successfully connects and the application and the device freezes at the point where I have set the breakpoint, but Eclipse does not give focus to the code line where it has paused.
The Run menu has all debug commands greyed out (step over, step into etc). I have opened the DDMS perspective and can see that the debugger is successfully connected. I can find my process there and stop it, and it gives the expected result on the phone. I have also tried all suggestions from this thread to no avail, but then again it tries to solve a different problem (not connecting).
Any suggestions?
more info: I have tried also the follwoing:
Uninstalling the app from the phone.
Rebooting the phone.
Restarting ADB.
Restarting eclipse
Rebooting the computer
Operating system is Windows 8. Eclipse version Juno. I have successfully debugged only days ago so there must be something I did that made this stop working.
Try going to the "Devices" View (Window > Show View > Devices).
In it, search for the process of your application, select it, and click at the button.
After that, run your application in the debug mode.

Android Debugging with Eclipse - No Breakpoints

I am trying to debug a simple Android application on either the emultor or a device and I cannot get the debugger to stop on any breakpoints I have set. I have combined the other posts here and throughout the web and tried all the suggestions (Add debuggable:"true" to the manifest, stop and start adb, Clean all, make sure I use the debug button not the run button, etc etc). In the Debug perspective I can see the threads and in DDMS it shows the debug icon next to the device I am debugging on. I do see the blue dots where I set the breakpoint and the Debug perspective lists them and says they are active.
I have put in alerts just before the breakpoints to verify the code is getting executed.
Starting to go crazy here. Any other suggestions? I must be missing something simple but non-obvious.
UPDATE: I appreciate the responses so far. Unfortunately they have not solved my problem. I have followed the instruction on debugging and have debugging turned on in the phone. Also, I do see the "Waiting for debugger" alert on the phone when starting. In general everything says I am debugging (including getting logcat output that I have added). It just will not stop on breakpoints that I have added and are listed in the breakpoints tab in the Debug perspective. Also just to reiterate - this happens when debugging on the device as well as on the emulator. One thing I do notice is that when I launch the debugger I have it set to bring up the Android Device Chooser. In there the "debug" column is blank for my device - but if the emulator is running the debug column does say 'Yes'. Also the console states that is attempting to connect to the debugger. Should there be a console log that states that the debugger successfully connected? I do not see this.
UPDATE 20120914: I have been away from this for some time and had given up previously. Back to try and tackle this. It is still not resolved. Everything above is still current - but one other thing I have noticed. I set a Class Load Breakpoint on the main activity and it does stop there. It just does not stop at any Line Breakpoints. I have just updated to the latest JDK 1.7.0_07, Android SDK 20, ADT Plugin 20.0.3. I have used the logcat to output a message and set a breakpoint on this line. I see the message in logcat so I know the code is being executed. The debug window in the debig perspective also does show the android application with a number of threads beneath it and the Devices window in the DDMS perspective shows the application with the green bug icon next to it.
One more thing - when the debugger is running the line breakpoints bullets do not get a checkmark overlaid on them (the Class Load Breakpoint does!). I am guessing this is the root cause - but I don't know why they are not getting this. (By the way skip breakoints is also not set - breakpoints do not have lines through them).
Any new suggestions would be appreciated. I have burned a lot of time on this. It must be something obvious that I am not seeing.
Now I feel a bit stupid writing this post. But I resolved my issue finally. The problem is you cannot set breakpoints in the Javascript code. The part I left out unintentionally is I am writing an app for Android using PhoneGap. Almost all the code is Javascript. I am so used to developing .NET web apps in Visual Studio I just assumed you could set breakpoints in the javascript code. Breakpoints in the Java code happen to work fine. Anyway, Thanks for any suggestions. Do';t know if there are other .NET developers trying PhoneGap development - but maybe this post will help them.
Android SDK provides most of the tools that you need to debug your applications. This link will introduce you to Android debugging environment and the debugging tools used.
Here's also a hands on tutorial on debugging an android application.
If you want to debug using actual android phone, turn on "USB Debugging" in your device:
Settings > Applications > Development and enable USB debugging
Android 4.0:
Settings > Developer options
AND make use of Log.d and your Logcat.
Eclipse has a debug run configuration. Only if you use the debug run configuration will a debugger be attached with the application during launch.
Does the application launch (on the device/emulator) pause a while "Waiting for Debugger" ? If not, then you are not launching the application using "debug configuration". Its the button to the immediate left of run (drop down) configuration.
Try jsHybugger: http://www.jshybugger.org/ for setting javascript breakpoints in Eclipse for remote(mobile) devices.
It lets you set breakpoints, singlestep, catch exceptions, and interact with the JS/DOM environment. You can use it from Eclipse or from a Chrome or Chrome-compatible debugger on the remote desktop. It can be used with apps that create their own webView.
However, you have to install a few files -- but probably no more complicated to use than weinre. it does extensively modify the JS files (on the fly, transparently to the user) to enable all this debugging -- webKit really should support javascript debugging natively.
Make sure you did not check skip all breakpoints (Run -> Skip all breakpoints).
Ribo already mentions it in his answer, but since this question and answers are about debugging Phonegap applications.
You certainly have to look at weinre (WEb INspector REmote).
http://people.apache.org/~pmuellr/weinre/docs/latest/
Nowadays phonegap even has it's own weinre embraced in phonegap build...
http://debug.phonegap.com/
I Am a big fan of this... (note if you are using weinre on your local machine and trying to debug a phonegap app via wifi... make sure your local device is on the same wifi network!)

Can't disable auto debug

In the meantime of programming my app, it occurred, that even if i push the "run" button in eclipse (not the Debug one) the application starts in debug mode. Even if i pull out the Usb cable and start the app manually over the phone menu, it "waits for the debugger to attach"...
After deinstalling and reinstalling the manual start works well (w/o debugger) until I get an error. Afterwards always the debugger connects...
Can anyone explain me whats going on in "eclipses" or "androids" head here?
THX!
"Use the perspective DDMS , and run your app, and then , you will see the icon of debugging in the process of your app , uncheck it and it will work ;
if id didn't work , open the perspective Debug ,then, disable all the breakpoints , and it will work
"
or maybe you can try to delete the current run/debug cofiguration from eclipse proprties. Take a look on this
Tried a lot way on this but nothing works.
But I just fixed this by terminating the process with 8600 port through DDMS process list in devices view.
I had the same problem. Tried all the above and had no solution. I found my fix. Click on the Debug perspective button. Once it's selected, right click on it and then select 'reset'. This stopped the debugger from being called even when I was selecting "Run" and not "debug".
On further evaluation.. The following fixed my problem. The issue seems to be in the phone and not Eclipse.. this is a rare problem. I only found a hand full of people with same issue.
1) Uninstall app.
2) Hard reboot phone.
3) Reinstall app.
Now, eclipse won't go into debug mode even when all the preferences are set correctly and you select 'Run' and not 'debug'.
I had the same problem . Simply delete the app on the phone and reinstall it. Restart the device. It works for me.
I tried different ways without results:
delete all breakpoints.
restart Eclipse, DDMS

Categories

Resources