开发者

Android adb "Unable to open sync connection!"

开发者 https://www.devze.com 2023-01-19 10:26 出处:网络
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:

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 开发者_JS百科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?


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.


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


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.


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.


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.


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


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


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


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.


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.


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


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.


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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


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!


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!


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.


Try this,

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

Settings -> Applications -> Development -> USB debugging

its works fine.


This solution worked for me

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

Android adb "Unable to open sync connection!"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号