Im trying to debug a very simple app i wrote from the Udacity course.
when i run the app in debug mode the app launches on the device, Debugger connects as said in line 1, the message
"waiting for debugger" is shown on my phone for a second. But when that message is gone from phone the debugger is automatically disconnected (line 2).
1. Connected to the target VM, address: 'localhost:8604', transport: 'socket'
2. Disconnected from the target VM, address: 'localhost:8604', transport: 'socket'
I read other question people had here with this issue.
tried rebooting AS, my device, killing adb server and closing Bluestacks.
The only way i managed to debug apps is by pressing Attach debugger to android proccess while i manually opened the app from my phone.
Any ideas? i really need debug option to work properly.
EDIT: When i run the app in normal state i get this log:
7-07 19:57:06.253 22333-22390/com.example.android.justjava I/OpenGLRenderer﹕ Initialized EGL, version 1.4
07-07 19:57:06.258 22333-22390/com.example.android.justjava D/OpenGLRenderer﹕ Enabling debug mode 0
Why debug mode is in 0?
This isn't exactly an answer, since I never understood why it happened, but the same thing happened to me and I resolved it by restarting both my computer and my device, and it has not recurred since. Believe it or not I put up with this for almost a week before it occurred to me to restart my device.
Related
Suddenly it is not possible to debug my android device. After a few seconds the device disconnects and i get the following message: "Disconnected from the target VM, address: 'localhost:49504', transport: 'socket'
I am using a Zebra Scanner.
I didn't change the code since the last time that i worked on that app.
I deselected all breakpoints.
I tried different activites.
Even by just starting the app in debug mode, it disconnets after a few seconds.
Running the app and attatching the debugger has the same result.
After the debugger reaches the breakpoint, the app process stops and after a little time (2-3 seconds) the debugger disconnect itself. But only if i debug with my Huawei phone (EMUI 10).
These are the last 3 lines from the log:
D/: [ZeroHung]zrhung_send_event: wp = 257, ret = 0
D/:[ZeroHung]zrhung_send_event: wp = 258, ret = 0
Disconnected from the target VM, address: 'localhost:8629', transport: 'socket'
If I debug the same app with the same breakpoint on an emulator, everything works fine. The debugger stops at the breakpoint, and doesn´t disconnect itself.
How did you build this project? If you build it with ant or other tools, make sure to compile with debugging information enabled (debug = true for ant javac tasks). Obfuscation and bytecode detection during construction can also affect the possibility of debugging. If you run it in some non-standard JVM, it can also cause such problems
When performing remote debugging, make sure to start the target process using the correct JVM options recommended in the IntelliJ idea remote debugging configuration. Your wrapper configuration may pass them incorrectly
I have a real Android device that I am using to debug. In order to attach Android Studio to my application, I ran this on the device:
adb shell am set-debug-app -w my.package.name
This worked fine. However, the problem is that now, whenever I try to open the application on my device, it will wait for the debugger to attach.
Waiting for Debugger
My Application (my.package.name) is waiting for the debugger to attach.
This happens even after I disconnect the device from my computer. Also, I restarted my device and nothing changed.
This is definitely not related to Android Studio, because my device is not connected to Android Studio, so any solution involving restarting Android studio would not work.
After looking at this page, I tried:
adb shell am force-stop my.package.name
This stops the application. But when I reopen it, it still waits for the debugger to connect.
So, any idea how I can remove this debug hook?
You can set/clear the debug app through Developer Options in your device settings.
If you want to do it through adb, it looks like you could do am clear-debug-app to clear it: http://androidxref.com/8.0.0_r4/xref/frameworks/base/services/core/java/com/android/server/am/ActivityManagerShellCommand.java#166
case "set-debug-app":
return runSetDebugApp(pw);
case "clear-debug-app":
return runClearDebugApp(pw);
I am perplexed by the behavior of Android debugger using Android Studio. It just cuts out during my debug session, then device not available. I seem to also lose all logcat files when this happens so don't detect a crash. App does not crash either so ... I am trying to debug a WebView and its corresponding WebViewClient but in the middle of my debug session the debugger just dies. Then it says that no device found when I try to rebuild and run as debug session. I have to unplug and plug back in the USB cord. Only then if I am lucky does the device reappear. But usually debug session lasts just a little while and then cuts off.
adb kill-server
adb start-server
Does not help. Device is no longer available. What could be going on here? Debugging debugger is really tough
Here is what console says:
Uploading file to: /data/local/tmp/com.myapp.debug
java.io.IOException: An existing connection was forcibly closed by the remote host
If I then try to debug again I get:
Uploading file to: /data/local/tmp/com.myapp.debug
com.android.ddmlib.AdbCommandRejectedException: device 'b3941da' not found
I have had this happen on two Android devices a Galaxy III, and Note Android 4.03. Not sure whats going on here. I do see power saving mode some times kicks in on one of the devices ... Turned off power mode, but still see this happening quickly right after trying to load app.
When Debugger gets cut off why is my logcat also destroyed? I mean what's the thinking in doing that? I get one entry left everything else whipped out:
01-01 00:00:00.000 0-0/? E/Internal: device offline
To be frank that's kind of frustrating .....
Now I also see:
Connected to the target VM, address: 'localhost:8600', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
Every time I try to debug any project with Android Studio, the app does not start, and immediately the console gives following message:
Connected to the target VM, address: 'localhost:8603', transport: 'socket'
Test running startedDisconnected from the target VM, address: 'localhost:8603', transport: 'socket'
I generally try to debug on my HTC Desire Z with Android 2.3.3 device and I remember that with Eclipse IDE the "debugging" works without any issues.
I finally solved it!
The problem was that at the left of start and debug button, the configuration menu was set to test. Just put it on App and now it works.