I set my android emulator to wait for the debugger for my application, so when it starts, the emulator waits writing in output log "waiting for debugger on port 8100".
But, I can't find a way to attach the Netbeans debugger to this port nor to the emulator in general...
Please help,
Alban.
There is an item in the Debug menu, labelled 'Attach Debugger...'
This item opens a dialog that lets you provide connection details.
Since multiple debuggers are supported, you may need to explicitly select the 'right debugger', which I assume is the Java Debugger.
There are a couple of gotchas that you might run into:
The Debugger may not have been activated. Open the Plugins dialog (Tools->Plugins) and activate the plugins in the 'Java SE' category are all activated.
The project that starts the emulator may not be debuggable. See this question and answer for more info.
Related
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.
I inherited some code that is having an issue when importing files only when the app isn't running. I was wanting to see if there was a way to hookup/monitor an app before it runs and be able to step through code.
The problem only comes about when importing starts the app. I seen that I could use DDMS for debugging logcat and the heap but I need to be able to step through the code with the debugger... at least I think I do.
In several latest API version (at least 21+), you can find:
Settings -> Developer options -> Wait for debugger.
which helps you stop for debugger during a debug application's startup
Once the app is running you can go to DDMS processes and click the bug icon. If you need to do it right before early code is run, you could put a sleep in before that code to give you a chance to start debugging your process. But if this sounds like too much trouble, logging is probably a better option.
Shift+F9 should start in Debug mode, which will attach the debugger before running. Alternatively, Run -> Debug '[app name]'
for android studio you can attach debugger by clicking on this icon and chose the right process.
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!)
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"/>
The app runs fine, but it hangs when attempting to connect the debugger, using Eclipse ADT plugin. Sometime shutting down the device will allow debugging to run again. What are the possible reasons for this. I have breakpoints in every create on every activity. What could be the problem? What is it really waiting for?
I had the same problem, only I hadn't realized some eclipse processes were still running since there were no more eclipse windows open.... Check for eclipse.exe as well as javax.exe.
Well it looks like this might have been related to having more than once instance of eclipse running. I separate instance running for separate workspace. Closing on instance appears to have fixed it in this case. might also need to set android:debuggable="true" in application element of manifest.
Sometimes you just have to reboot your Android device.
I have frequent issues with Eclipse, too.
Order I reset:
Disconnect USB, reconnect.
On Android Device, disconnect USB Debugging, reconnect.
Restart adb - In Eclipse go to DDMS screen, select the down arrow next to the camera and select 'reset adb'
Reboot Android Device (for constant problem with debug connecting)
Reboot PC (generally doesn't help)
Do not select any video source (your webcam), just let it empty when the application ask you to select one of them.
This happened to me when i attempted to debug a unit test by starting it from the junit view (right click -> debug as...) which failed and displayed the error message "Test launch failed due to internal error: Running tests on UI thread".
This was due to this bug http://code.google.com/p/android/issues/detail?id=34170
The fix for me was to not run from the junit view, but rather run from the debug button on the toolbar.
I'm using ADT 20.
My solution - works with "Windows 8 Pro 64-bit", "Google Nexus" and "Android Developer Tools Build: v21.1.0-569685"
Close any Eclipse instance.
Ensure no application is listening on port 8061, you can use: NETSTAT -B in Windows command line to list all ports listened by applications. Sometimes, adb.exe or javaw.exe are still listening on 8061 port, even you think Eclipse is closed.
Close javaw.exe, adb.exe until 8061 port is free.
You'd have probably figured this out in 4 years, but I am so happy after I found the problem that I want to someone to know about it.
For me there was a breakpoint on variable declaration in MainActivity Class. This variable declaration wasn't a part of any method and the statement itself was never executing. And there was no other breakpoint in entire application. Once I put the breakpoint at correct location (onClick method), everything fell into place.
Don't know if this worked for you.