168

I can run and debug my Android app on my phone just fine, most of the time. Then, seemingly randomly, when I try to run or debug my app from Eclipse, the Console in Eclipse says:

[2010-10-12 09:36:48 - myapp] Android Launch!
[2010-10-12 09:36:48 - myapp] adb is running normally.
[2010-10-12 09:36:48 - myapp] Performing com.mycompany.myapp.MyActivity activity launch
[2010-10-12 09:36:48 - myapp] Automatic Target Mode: using device 'HT01TP800561'
[2010-10-12 09:36:48 - myapp] Uploading myapp.apk onto device 'HT01TP800561'
[2010-10-12 09:36:48 - myapp] Failed to upload myapp.apk on device 'HT01TP800561'
[2010-10-12 09:36:48 - myapp] java.io.IOException: Unable to open sync connection!
[2010-10-12 09:36:48 - myapp] Launch canceled!
  • Retry: doesn't help, same messages.
  • Restart Eclipse: doesn't help.
  • Restart adb (adb kill-server && adb start-server): no errors, doesn't help.
  • Reconnect the phone: sometimes helps.
  • Reboot the computer: kind of drastic, haven't tried this yet.

Using Ubuntu 10.4, Eclipse Galileo 3.5.2, Android SDK 7, ADT plugin 0.9.6, Nexus One, Android 2.2.1.

Any bright ideas?

Jon
  • 9,156
  • 9
  • 56
  • 73
Thomas
  • 174,939
  • 50
  • 355
  • 478
  • 2
    Same issue here on a Nexus One. It's a horrible and desperating problem, testing in the emulator is so slow... The weird thing is I'm the only one having this problem and we are 5 developers sharing the same phone. I'm using windows and it also happened on previous sdk versions (2.0 and up) – Maragues Nov 24 '10 at 10:36
  • 2
    Same here. Sometimes cycling "Allow Debug Connections" fixes it, sometimes pulling the USB cable fixes it, sometimes NOTHING fixes it until tomorrow (I assume that can be explained by the gravitational affect of the moon). I've tried moving from the USB hub to a direct port but that had no affect. Vista x64 user here. – Skylar Sutton Dec 31 '10 at 02:22
  • 1
    (I assume that can be explained by the gravitational affect of the moon) this sounds interesting. I noticed an accumulation of this effect on thursdays with newmoon. – Simon Lenz Jun 03 '11 at 21:34
  • Somebody should protect this question. It is starting to get a lot of duplicate answears and "me too" comments. – Magakahn Oct 10 '12 at 09:51
  • that did the trick. i was wondering if the usb cord was failing. first year of developement is getting hit with all the odd things that go wrong and researching and remembering the fixes. – Androidcoder Mar 17 '13 at 21:32

18 Answers18

415

I was having exactly the same problem, but I already had my phone connected to the computer's USB port. Sometimes disconnecting and reconnecting the cord worked but then it stopped working completely. However, disabling USB debugging on the phone and then re-enabling it has worked so far. Hopefully it keeps working! These fixes really seem like silly hacks.. I'm not sure what the underlying problem is.

Maven
  • 4,166
  • 1
  • 14
  • 4
  • 1
    Luckily I have this issue not even once a day and simple reconnecting the usb cable works fine, always... – WarrenFaith Dec 17 '10 at 00:46
  • I had this and the cable unplug/replug usually worked but today it needed the USB enable/disable 'tweak' to the process. Not sure if it's just superstition though and it's the delay in navigating there to enable/disable the debugging option that is doing the trick. Anyhow thanks for this post as it was driving me up the wall! – sradforth Apr 05 '11 at 15:50
  • 6
    Seeing the same problem. Unplug/plug does not solve it. Toggling USB Debugging (without plug/unplug) DOES solve the problem for me. Anyone have a widget for doing this? – James Moore May 25 '11 at 16:06
  • In case you don't remember how to enable/disable USB Debugging: http://www.youtube.com/watch?v=_8C-O51n7B8 – Caner Aug 08 '11 at 10:34
  • +1 for me too, I was rebooting everything, plugging/unplugging cables, and then searched the web. Disable -> Enable USB debugging did the trick. – Andras Balázs Lajtha Oct 18 '11 at 06:55
  • I need to do this several times a day while developing/testing and it works every time. The only issue is that it's annoying to even need to do this. I came here looking for a more permanent solution, which doesn't seem to exist. – Pilot_51 Jan 16 '12 at 21:09
  • Open this app each time you have this problem to fix it: https://market.android.com/details?id=fr.adbfix.android – ldiqual Feb 06 '12 at 15:19
  • 1
    Seriously why is android always so faulty!? – Pacerier Feb 16 '12 at 01:38
  • This fix worked for me just now while debugging over tcp/ip (specifically over wifi with the phone acting as hotspot) in which case there was no USB cable involved. I used the same procedure of toggling "USB Debugging" in the application/development settings. – ahcox Feb 17 '12 at 17:10
  • same issue here. solved by disabling / enabling the USB debug option. very annoying.. :| – Mario Fraiß Mar 19 '12 at 20:57
  • 1
    Thanks for the solution mate. To be honest though, Android programming itself seems a series of silly hacks to me. Many things do not work as per intuition - and I often find either undocumented features being necessary, or some kind of other gimmick solves it. – KalEl Jun 03 '12 at 22:06
  • [There's a nifty app that does this.](https://play.google.com/store/apps/details?id=com.pixplicity.adb) Unfortunately it requires root, but it's especially handy on my SGS2 since I have to unplug the cable, plug it in again, close the USB mount window and head through the menu a second time. – Paul Lammertsma Jul 13 '12 at 13:58
  • "**disabling USB debugging on the phone and then re-enabling it has worked so far.**" Thanks, worked like a charm ! +1 – Ldev Jul 18 '13 at 10:07
  • if it doesn't work turn off your device then on, it will works !! – Chris Sim Dec 06 '13 at 07:13
25

I was able to clear this only by cycling the USB Debugging option on the phone.

  • 11
    Settings -> Applications -> Development -> USB debugging – Thunder Rabbit Jul 07 '11 at 00:58
  • 1
    How that differs from the accepted answer ? [Also you mean toggling](http://dictionary.reference.com/browse/cycling?&path=/) – Mr_and_Mrs_D Jul 21 '13 at 00:58
  • It is Differ from main Connection because of some port of device not work proper some ports disable either your debug mode is on so you have need to Debugger disable and then re enable from device.......... – Amitsharma Jan 09 '15 at 09:55
3

This may also be related to a "too many open files" issue. I manually tried to install the app when getting the "sync" error above and that's when I got the "too many open files" clue. one brute workaround, based on some old posts, seems to be to restart the phone, and one google engineer suggested doing it twice, the second time before it goes into sleep mode the first time (details on why in the post).

That was a few years ago, and maybe they've fixed it, or just did some things to get around it in the usual cases and the reinstall-as-part-of-development is not a case that it addresses.

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
user655489
  • 1,316
  • 3
  • 14
  • 21
3

Nexus One here, CyanogenMod 7 (Android 2.3.7)... disable and reenable:

Settings > Applications > Development > USB debugging

And everything works now on Eclipse and Mac OS X 10.7.3.

whiskito
  • 31
  • 4
2

I have been having the same problem when I have the phone connected through my keyboard's USB hub. IT went away when I connected straight to the computer's USB port.

Juhani
  • 5,076
  • 5
  • 33
  • 35
2

This error occurs when somehow the Android Debug Bridge , which is the tool to send data from our computer to the connected device, disconnects. As we know, there are some layers to get connected like the adb itself and of course, the last layer is the USB cable, so when you already tried to restart your adb script and seem not working, you just need to reconnect your cable.

Enrique Diaz
  • 573
  • 4
  • 13
2

I have had the same problem and restarting ADB wouldn't work for me. Sometimes rebooting my phone worked but not always, I was unable to program for about a week because of this glitch and I think I finally found a workaround! :-D

First of all, kill every program running on your phone. Having some kind of taskmanager makes this a quick task, otherwise you'll have to manually kill them all one at a time.

If that doesn't fix it, you will need to go to your phone settings, then go to "Applications", then go to "Running services", and kill every service in there. I'm using a Droid Incredible and I have yet to have this not work for me. :-)

So, the short answer is, kill all apps, and all services.

Also, keep in mind, you will need to close, and re-open eclipse to see if this fix has worked for you. I hope this works for you, I know it did for me! :-D

Jared
  • 2,999
  • 1
  • 28
  • 39
2

When this happens on the Kindle Fire I just power it off and back on again.

HalR
  • 11,411
  • 5
  • 48
  • 80
2

I fixed it just by disabling and enabling the debugging configuration on my device (SonyEricsson Xperia)

rolimat
  • 21
  • 1
1

What helps for me is the following: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

If you are debugging on AndroidX86 (or otherwise have root access to your Android developer machine) Kill the "adbd" process.. and let it restart.

e.g.

[On Android VM]

  • kill adbd (e.g. kill `ps a| grep adbd | awk ' { print $2 } ' `)
  • /sbin/adbd will restart automatically

[On DEV station]

  • [dev station] ./adb disconnect
  • [dev station] ./adb connect

If you don't have root, probably toggling USB debugging, rebooting, etc could also help. As it also restarts adbd ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1

I see this problem regularly in both attached devices (Phone or Tablet) and even the emulators. I noticed that the problem often follows periods of inactivity (after a lunch break for example). It may be that the Operating System on the development machine is trying to conserve resources and adb just isn't all that JIT friendly. On windows I have to close the IDE and open Task Manager and force stop (kill) adb, then relaunch Eclipse. This always works for me...

  • I noticed if I set a higher priority in task manager for adb, this problem is greatly reduced--although it can still happen.
Rob
  • 49
  • 2
1

Restarting the phone has also fixed this problem for me whenever reseting the usb cable didnt fix it

Kurru
  • 14,180
  • 18
  • 64
  • 84
  • disabling and enabling USB debugging didn't work for me. I tried to restart the device .. everything worked fine. I think this error is related to many apps or services working on the the device so when i restart it or task manager - > Ram - > Clear Memory will save the problem – Chris Sim Jul 12 '13 at 09:06
1

The solution is likely to run on your android phone (on local terminal or ssh terminal): $ stop adbd; start adb

I don't like overkill solutions like rebooting hte phone... and this is usually not needed under Linux. I experienced the same problem when connecting over Wifi, so USB is maybe not responsible at all. Reading the answer from user655489, I got the idea to run lsof, and then lsof | grep adbd | wc -l => I think I had over many sockets open with all FD from 0 to 1023 in use... how suspicious.

I ran killall adbd, then restarted adbd per How can I connect to Android with ADB over TCP? And the problem was gone.

The cause is that, at least when debugging and having to kill my non-working apps, that several of the sockets never get closed.

Community
  • 1
  • 1
0

I experienced this problem when my USB cable was connected to PC via keyboard USB :O. When I connected it to PC directly my problem solved.

I hope this works.

Enjoy!

Bob
  • 22,810
  • 38
  • 143
  • 225
0

As per Maven Explanation I tried this solution. but I was getting the same problem. So I restarted the device. And it started working perfectly.

Community
  • 1
  • 1
Narendra Pal
  • 6,474
  • 13
  • 49
  • 85
0

Try this,

Disabling USB debugging on the phone and then re-enabling under

Settings -> Applications -> Development -> USB debugging

its works fine.

Silambarasan
  • 767
  • 5
  • 19
0

This solution worked for me

  1. Click Revoke USB debugging authorizations.
  2. Click OK.
  3. Reattach USB.
  4. Click OK for Permissions.

enter image description here

Siddarth Kanted
  • 5,738
  • 1
  • 29
  • 20
0

I have been experiencing this problem very often (I mean like every second time I launched Debug). I was using a rather long USB cable. I switched to the original HTC USB cable which is short and the problem was gone!

Daniel Novak
  • 2,746
  • 3
  • 28
  • 37