Android debugger continually disconnects - android

I have never had an issue debugging in Android until I switched to my current workspace. It happens in both Eclipse and IntelliJ. Previously I had an issue where the phone would hang at the "Waiting to attach debugger" dialog. Somehow I fixed that so the debugger at least attaches to my app.
Now I can set a breakpoint and have the debugger stop at that point. After about 5-10 seconds it disconnects no matter what I do. I'm able to read a few values of variables in memory before everything disappears. My co-worker is able to debug the same app just fine using Eclipse and we haven't been able to figure out what is wrong or different between our workstations (besides me using IntelliJ). We might have different images for our laptops though.
Any ideas? I've had to use Log statements for now but they are just too slow compared to using an actual debugger. I've tried using different USB cables and that didn't make much of a difference. I've gone through the debugger settings and nothing seemed out of the ordinary. Other Q/A's on SO have mentioned the app silently crashing, but I'm ruling that out due to it debugging fine for my co-worker.

I've been having the same problem running IntelliJ IDEA build IC-133.193. I solved the problem with the following actions:
Quit IntelliJ
From a command line kill the adb server with adb kill-server
From a command start the adb server as superuser with sudo adb start-server
Restart IntelliJ
IntelliJ will start the adb server if it detects that it is not running. The key appears to be starting adb as superuser before starting IntelliJ.
[Update] This doesn't always work. The best solution I've found is to start the app on the device and then attach the debugger to the Android process through the Run menu. I haven't had any disconnections using this method.

I have been fighting for a few days with adb not seeing my device. After trying many other posted solutions, I discovered that the issue was with Chrome also trying to connect its debugger to a web view. If Chrome is connected using chrome://inspect, then adb seems to disconnect. Quitting Chrome resolves the issue. Then I can connect with Android Studio and then restart Chrome and reconnect. Hope this helps someone else.

This fixed it for me
Go to Power Options on your computer
Click 'Change plan setting' on your chosen plan.
Click 'Change advanced power setting' on your chosen plan.
Expand 'USB Settings' .
Expand 'USB selective suspend setting' and change it to disabled.

This issue occurs to me when I try to use a USB 3.0 port. Using a USB 2.0 it does not happen.

This happens to me when the cable connection is sensitive.

Related

Android device keeps disconnecting from adb / eclipse

So I've read nearly every stack overflow answer about this issue, but still no solution. My device keeps getting disconnected. I've switched through 12 wires, I've tried every USB port; nothing. Eclipse keeps dropping the connection. It happens most often when I enter debug mode. Has anyone found a solution to this? Is this a bug in the new update? Seriously, this makes debugging and testing so painful. It slows down my testing by at least 3 times. There has to be a better solution.
First thing I tend to try is the following commands in cmd/terminal
adb kill-server
adb start-server
And lastly,
adb devices
To check the device is connected.
Following that I'd try restarting the device, and perhaps as a last resort uninstall/reinstall it's drivers.
Edit: also, do you have access to another device? In the past I've had issues with specific devices constantly dropping out.
I experience that when my nexus7 2012 kept disconnecting; root cause was the USB3 connection.
Changing to a USB2 port fixed my issues; can you try switching to a lower speed port?
I was having a very similar problem but using Android Studio on OS X. By default Android Studio points to an SDK inside it's application bundle so I changed the SDK location setting to point to another version of the Android SDK I had downloaded manually and this seems to have fixed the disconnection issues I was having.
Instructions for changing the SDK location setting can be found in this answer.
My connected device (an Acer) was working a treat until I rebooted my mac. After the reboot, Eclipse dropped the connection every single time I ran the app. I tried two cables and every port in my iMac but nothing worked. I had to disconnect and reconnect the device for every run (a real pain when debugging!).
What worked for me was to run the app. When the window appeared to choose the device to run on (which was empty), I disconnected then reconnected the device, but before clicking to run, I checked the box (bottom left) to use this device for each run. It now runs every time directly on the device.
a unpowered usb hub did fix the problem for me. it was happening on both my samsung s6 and my sony z5 premium.and both on my pc and my mac. (using android studio).
Use short usb cable. The shorter the length of cable, the more stable the adb connection. I had the same problem for long time. I changed the cable to shorter one and I haven't got that problem anymore.

Android app not running on the emulator

The emulator won't launch my apps even on a real device! I've tried every solution online, even reinstalling android sdk,ADT plugin. The app run SOMTIMES(4x to be exact) though, like awhile ago, when i got home i tried it again, and it run on my first try then i began working on the code again then i tried to run it, won't run again. Even basic apps like hello world won't run most of the time. I've set the run configuration to let me choose my device everytime, but even the device chooser wont show up(showed up once only), i tried waiting for 30 minutes(also tried the kill-server start-server) but it just wont run! my real device, or the emulator is listed on the DDMS perspective and there's nothing on console. please help, cause I've wasted 2 days for this already.
Have you also tried, taking the USB cable then disabling debugging and then enabling debugging and putting the USB cable back.
I remember this happen to me, so I did what I mentioned and surprisingly it works. Hope it work for you too.
Maybe you should try deleting your emulator and creating a new one. Make sure that all your settings are correct and that you are targeting the right OS version.
I've had quite a few problems with the emulator and wiping them and starting from scratch worked more often than not.
As for the real device, the first real hurdle is getting the right drivers so that your PC can recognize it, after that kill-server start-server usually does it. I'm surprise that didn't work for you.

Adb stops detecting my phone after a while

I am developing for android on a linux machine and I have already created a udev rule for android and it works. After a while if I unplug the device and plug it back in again, adb doesn't recognize the device if I run lusb or dmesg to get information about the device. I tried reload the udev rules and it does not work, I even tried to kill the adb process but it still does not work.
Can someone help?
Anyway, thank you.
This appears to be a real problem on linux, at some point in time a device will no longer be seen by the ADB. What I should really say is almost never be seen by the ADB. In my case I have a Samsung Galaxy Tab 10.1 that was given to attendees of Google I/O 2011. My Ubuntu 10.10 development system was working just fine with this device. Sometime near September 19th the ADB stopped seeing the device! In fact there have been breif moments in time when the device was detected by the ADB. What needs to be made clear about the problem that I and I believe pharaoh are having is not the permissions issue where executing
$adb devices
returns ?????????? for a device. The device simply does not show up in the list. One more important fact is that at no point in time has this device not been detected on my Windows based development machines.
It appears to me that the mechanism that the ADB uses to determine if a device on the USB is in fact a adb_device is fragile and some change in either our devices or our development systems has broken this detection.
Due to some reason sometimes adb gets disconnected, so in that case you have to restart the adb.
Go to DDMS->Devices and you will see Reset adb option in View Menu besides Screen Capture option.
I usually have this problem due to I have installed the adb plugin on Chrome. If I close Chrome and re-connect the device, it appears listed with adb. Hope this helps.
I just had this problem as well with my OnePlus 2.
It was working the previous day. I had then set up port-forwarding using the 'device inspector' dialog in Chrome DevTools. It's supposed to be kept open for it to work, so I kept it open in a tab permanently.
The next day when I connected my device via USB, adb devices didn't list anything. I closed the device inspector dialog in my devtools and suddenly adb recognized my device again. I re-enabled port forwarding after this, but my device is stll being detected.
tl;dr: Close your port-forwarding dialog in Chrome DevTools if it had been kept open even after you removed your device.
I've had this happen before. I disable, and then re-enable debugging on the phone (Setting -> Applications -> Development -> USB debugging, uncheck, then re-check) to get it recognized by adb again.
Try adb kill-server to stop the adb and use another command 'adb devices' to restart it. It should work and it should detect your device again. ( For those who can edit my post: any other commands will start the server not just adb start-server, so don't edit without to leave a comment at least)
May be stupid, but I have been had similar problem right now and after an hour I noticed that the problem was that my USB hub, in which such devices are connected, were not actually connected to the PC.
In fact, the USB wire WAS connected, but they may not being doing good contact for some reason, so it failed randomly from time to time.
Same problem here, using mac os. However connected devices are recognized by Android File Transfer application. It all started with S3 phone (rooted), I thought something wrong with the phone, because Nexus 7 (stock) worked as intended. After 3 days of connecting/reconnecting it stopped being recognized by adb too. Tried to perform a hard reset - didn't help.
adb list - empty list
android file transfer - works perfectly
I'll run out of devices soon
Same problem observed on ubuntu, I tried the following and it worked:
Reference: link
Use the command udevadm from the above reference for ex:
"sudo udevadm test --action="SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="[vendor_id]", ENV{ID_MODEL_ID}=="[model_id]" MODE="0666", SYMLINK+="[Device_Name]"" $(udevadm info -q path -n /dev/bus/usb/001/[DevNum])"
This seems to fix some link files and that solved the problem of adb not detecting device after a while.

Android ADT Debugging Hangs Attempting to connect to debugger on port 8601?

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.

Reconnecting Emulator to Eclipse

My main problem with developing in Android is that the emulator seems to continually get disconnected from eclipse. This always happens the 2-3 time I try to upload my .apk from eclipse without rebooting the emulator. Eclipse indicates this with an empty DDMS ->Device section and logcat stays blank - sometimes I'm not sure if the new code made it on the device.
The only fix I have for this is to shut down eclipse, and restart it. With the restarting of Eclipse, on top of the emulator boot time, I can't get any momentum going in my development.
Is there a way to reconnect the emulator to eclipse without having to restart Eclipse or even the Emulator?
Update: There were a couple of answers that helped, particularly "reset adb" or Kill-server -> connect adb. However, sometimes even that is troublesome.
I am going to try Pentium10's suggestion of hooking up my G1 and using it as an emulator, but for now, I have found that if I don't see my logcat going, and the emulator is working (This is my biggest problem, because I am outputting all my debugging messages to log) then I can open up CMD and type adb logcat. This streams the log into the command window. Not nicely color coded, but nice enough for me to find my problems...
In eclipse go to Window->Show View->Other->Android->Devices. When your application is run go to this tab and you will see the emulator. If your emulator becomes unresponsive, in the devices tab you will see a down arrow at the right. Click the arrow and a context menu shows up. Hit the option Reset adb.
Just had to do this and it worked beautifully, but it did require you to reset the emulator - though I didn't wait to see if it reconnected on its own.
Try to call 'Reset adb' menu item from DDMS > Devices tab. It helps me in this case.
At most of the time you don't need to restart the emulator.
AFAIK the only workaround for this is to restart Eclipse (I always use this), or use a real phone.
Try adb kill-server, followed by an adb connect
I've had luck reconnecting to the disconnected emulator by entering an adb-over-tcp command line which you can look up in the docs. I think the address and port to use are the ones in the title bar of the emulator window, if not try the next higher port. Once it's back in adb devices eclipse should use it.
in terminal:
$adb kill-server && adb start-server

Categories

Resources