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!)
Related
2 days ago my chrome remote debugging of my ionic application was working perfectly. Now however with no changes my remote debugging will not display scope variables.
The Scope section of the remote debugger just says: "Not Paused". This appears always, including when the application is paused on a breakpoint.
I am guessing that the issue may be related to the fact I am debugging with source maps. I did a quick debug session vs a normal web page running in chrome on my tablet, and I could see scope variables that way. This leads me to believe it is potentially related to using source maps.
Additionally, there is an error at of the top of the debugger that says:
"Consider disabling Chrome Data Saver while debugging".
I can't say for sure if this error was always there or not, but I don't recall it being there previously.
However, data saver is off on both the PC and the tablet, which seems it should preclude that error from being shown.
I have been searching but I have only found one other thread related to this issue, and it appears it was never resolved. However, the thread matches my issue exactly:
https://github.com/google/WebFundamentals/issues/4463
Attached is a screenshot of the problem in action.
Debugger screenshot
I can still use the Watch section to see what is going on in my scope variables by typing them in (as you can see in the example screenshot).
Here is the chrome version information off chrome running on my PC:
Google Chrome 65.0.3325.181 (Official Build) (64-bit) (cohort: 65_win_181)
Revision dc3469be277cc962ba01d9c0cb5bb1a265676c36-refs/branch-heads/3325#{#725}
OS Windows
JavaScript V8 6.5.254.41
I have a Galaxy Tab A (2016) with S Pen.
The tablet is running Android version 7.
Any ideas anyone has to figure out what is going would be very appreciated.
Will
Eventually, for reasons I could not figure out, my app lost the ability to speak to my computer over WebSockets altogether.
Running this command seems to have fixed both my original problem and my new problem.
cordova plugin add cordova-plugin-websocket
I already had a websocket lib installed, but perhaps this one was better.
I hope that helps anyone else that has gotten stuck with this problem.
Will
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.
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"/>
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.
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.