DDMS won't allow debugging - android

I'm attempting to use the DDMS debugger to connect to a process on a Nexus4 device. I've built a debug version of the application, added android:debuggable="true" to the manifest and also added android.os.Debug.waitForDebugger(); to main MainActivity.
However the debug icon in DDMS remains greyed out, even though I can see the device and the application the DDMS list.
Any suggestions on how to resolve this?

How to use Monitor (DDMS) tool to debug application step by step?
check this post you will get the answer.
In App Toolbar you will find "Android Device Monitor" just right beside the "SDK Manager". Click on this your DDMS will run.
but
Problems:
1. It will close any adb connection and any debugging process.
2. Unfortunately You will not be able to put debugger on any selected process. even this is a very good way of debugging your application.
Don't know why Google/InteliJ/Studio Developers are not fixing this issue.

Related

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

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!)

"Waiting for debugger to attach" showing even when not running in debug mode

My problem:
I ran upon an awkward problem as I was developing my application. As mentioned in the title, every time I install my application (in run mode, not debug!) at start-up the waiting for debugger to connect.. message appears for 1-2-3 seconds, and the application starts.
What I want:
What I would like is to be able to start the application without that message appearing (it only started appearing in the last few days, and I can't remember changing anything related to debugging).
What I've tried:
I have tried setting the android:debuggable="false" but if I do this the debugger never attaches and the message never disappears.
I have also tried after installing to disable USB Debugging, but still no results.
Even if I kill the application and wake it up through an external source (it uses Google's C2D Messaging Framework) it still tries to run in debug mode on wake-up.
I have developed several Android applications and never stumbled upon this. Why wouldn't I be able to start the application in RUN mode? Is there any other way to install the application on the device, without hitting the run button in Eclipse?
I can post code-snippets from the AndroidManifest or from other parts of the code if necessary, but as I already mentioned I wasn't getting this kind of weird behavior several days ago.
Make sure your java files dont have any break point and Restart the device every thing should be normal.
I was experience the same problems where my application was always being run in debug mode. Restarting the device did the trick for me.
and make sure you are using
right click on project-->>Run As -->> Android Application
For me the solution was turning off the USB debugging from my device settings, and then turning it on again!
Much quicker than restart the whole device.
I had the same problem using Android Studio. Restarting my cellphone worked for me!
1. Open setting in ur phone.
2. Go to developer options.(About Phone-> Developer Option).
3. Disable the Developer option and again enable the Developer Option.
4. Enable USB debugging and Install via USB.
Run this command and the issue will be resolved
adb shell am clear-debug-app
Check if the option waiting for debugger is actived.
Settings -> Developer options -> Wait for debugger.
I think this it is new from Jelly Bean.
I'm assuming this is in the emulator and not on a device. If it is a device, ignore the rest. :p
It sounds like you saved a snapshot of the emulator as the debugger was connecting.
To fix:
1) Go to the AVD control panel, click on the emulator that's affected and hit start
2) when the window pops up, de-select "Launch from snapshot" and leave "Save to Snapshot" selected
3) Start the emulator.
4) Close the emulator
5) On the AVD control panel again start the emulator
6) Check "Launch from snapshot" again
That should fix things up.
EDIT.
Sorry for the wasted space, I read too fast and missed you talking about trying disabling USB Debugging. I have run into the above situation I describe before so I'll leave this answer posted for those who come along who do have such an issue.
"Wait for debugger"in Developer options may have been set to wait your application.
Do check once that you placed breakpoints. Run app once and if you get the same message do debug as-> debug configuration-> select the app which you need to run and select always prompt to pick device.It will work for sure. It may be stupid, but i faced this problem for a long time and i tried this and this helped me. And if needed restart your device. Thanks
For me, I use Android Studio 2.1.2I, I click on Menu Run > Attach debugger to Android process
There is only 2 lines
__device_name
____app_name
I just select app_name(want to run) and click OK then miracle happens.
I had the same problem.
But restart my Device or clear the Breakpoints don't worked.
I tried :
Run --> Attach to Android Process.
Select your package and press OK.
and it works :)
There was so many adb processes running ,I kill them all and its start debugging
You can also set your Android App as Debugging-App
Settings --> Developer Options --> set Debuging-App
there you can choice your app
You might have added your app in Select app to be debugged on your phone. In Settings -> Developer Options -> Select app to be debugged
To resolve this, go to Select app to be debugged and click on No apps
Your manifest file may contain following permission
Just remove this permission
<uses-permission android:name="android.permission.SET_DEBUG_APP"/>

Help a newbie learn Eclipse/Android debugging best practices

I am a newbie to Android and the Eclipse development environment and would like some advice on best practices for debugging my apps when they throw a Force Close.
I have researched ADB, however, I can not get this to interact with my phone even though I have explicitly turned debug mode to true on my test handset.
Obviously Android comes with a LOG method which I have seen utilized in many example apps, can someone please explain how to review these logs quickly and how to setup logging appropriately to determine the cause of a Force Close (always occurs when I push the Home button).
Any advice on debugging effectively in Eclipse would be much appreciated!
Sincerely,
Ryan
To debug using your device, you will need to have debug mode turned on (which it sounds like you do), you will then need to have the phone plugged in with the USB connector. From here, you can tell Eclipse to run/debug.
Eclipse should ask which device to use (this is done because there should be multiple devices available for running/debugging since your device is plugged in). At this point, you can select your actual device from the list, and you should be up and running.
If you are using android.util.Log, then your logs will show up in LogCat. If you do not see LogCat by default in your Eclipse environment, you can add it by doing the following:
Go to Window -> Show View -> Other
Select Android -> LogCat
Cick OK.
When running/debugging your device, you should see your Log statments in LogCat.
As I have never been able to get Eclipse to refresh the LogCat when I'm debugging on device, I will add this :
You can also debug from command line like this :
"adb -d logcat"
However, as the windows command line is awfully basic, the line are cut in 2 most of the time.
And my asking about your OS does help because the procedure is not the same to set up device debugging if you are on windows or linux or mac.
For instance, in the case of windows, you need to install a driver (you can find all the doc here) before being able to debug on a device.

DDMS Not Showing Threads From Device

I'd like to check for memory leaks in my Android app using the DDMS feature in Eclipse. When I launch an emulated device, the threads display properly for the emulated device, starting with 8600 and up.
However, when I connect my Droid to the PC, the device shows up just fine in DDMS. The logcat is generated correctly, and I can view the file structure. However, threads do not display. I get "no client selected" in the Threads pane, and there is no drop-down icon next to the device listing.
Do I need to change some particular setting in Eclipse? Is this maybe a driver issue?
Eclipse Preferences (OSX) > Android > DDMS > check Thread Updates Enabled by Default
Add Android Device view to get device pan(e) noted above
Set android:debuggable=true (two g's) in app tag as noted above
Run your app in emulator
Select device in device pane
Click the update threads button
Enjoy
Make sure you have android:debuggable="true" in you application tag in the manifest file
This is expected behavior. The issue is your droid is not in debug mode. Notice that in the Devices pane, beside the version number, debug is stated against the emulated device but not in the case of the droid.
From what I have found so far - on the droid, only an app can be run in debug mode; and only this will be listed under your device in DDMS.
I don't know how to run(/boot) the entire droid in debug mode, or if it is possible. So far as it appears, there is no way to boot an entire real device in 'debug' more.
Go to DDMS
Select device in device pan
Look at header of this pane. You can see update threads
You can see thread and updates from device
If you use Intellij Idea like me - run monitor from tools-> android, other way Idea built in ADB conflict with ddms.
On Android Studio :
On the DDMS (Dalvik Debug Monitor Server) Screen:
Show View -> and then select the profiling view you need.

Categories

Resources