Android adb“无法打开同步连接!”

发布于 2024-09-27 01:28:55 字数 1005 浏览 13 评论 0原文

大多数时候,我可以在手机上运行和调试我的 Android 应用程序。然后,当我尝试从 Eclipse 运行或调试我的应用程序时,看似随机地,Eclipse 中的控制台显示:

[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!
  • 重试:没有帮助,相同的消息。
  • 重新启动 Eclipse:没有帮助。
  • 重新启动 adb (adb Kill-server && adb start-server):没有错误,没有帮助。
  • 重新连接手机:有时会有所帮助。
  • 重新启动计算机:有点激烈,还没有尝试过。

使用Ubuntu 10.4、Eclipse Galileo 3.5.2、Android SDK 7、ADT插件0.9.6、Nexus One、Android 2.2.1。

有什么好主意吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

年少掌心 2024-10-04 01:28:56

该解决方案对我有用

  1. 单击“撤销 USB 调试授权”。
  2. 单击“确定”。
  3. 重新连接 USB。
  4. 单击“确定”获得权限。

输入图片此处描述

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

几度春秋 2024-10-04 01:28:55

我遇到了完全相同的问题,但我已经将手机连接到计算机的 USB 端口。有时断开并重新连接电源线可以工作,但随后它完全停止工作。
不过,到目前为止,在手机上禁用 USB 调试然后重新启用它是有效的。希望它能继续发挥作用!这些修复看起来确实很愚蠢。我不确定根本的问题是什么。

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.

不爱素颜 2024-10-04 01:28:55

我只能通过循环手机上的 USB 调试选项来清除此问题。

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

我的痛♀有谁懂 2024-10-04 01:28:55

这也可能与“打开文件太多”问题有关。当出现上述“同步”错误时,我手动尝试安装该应用程序,此时我得到了“打开文件太多”的线索。一种粗暴的解决方法,基于 一些旧帖子,似乎是重新启动手机,一位谷歌工程师建议做两次,第二次在第一次进入睡眠模式之前(帖子中详细说明了原因)。

那是几年前的事了,也许他们已经修复了它,或者只是在通常情况下做了一些事情来解决它,而重新安装作为开发的一部分并不是它解决的情况。

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.

昇り龍 2024-10-04 01:28:55

此处为 Nexus One,CyanogenMod 7 (Android 2.3.7)...禁用并重新启用:

设置 >应用领域>>发展> USB 调试

现在在 Eclipse 和 Mac OS X 10.7.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.

烟沫凡尘 2024-10-04 01:28:55

当我通过键盘的 USB 集线器连接手机时,我也遇到了同样的问题。当我直接连接到计算机的 USB 端口时,IT 就消失了。

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.

鸠魁 2024-10-04 01:28:55

我遇到了同样的问题,重新启动 ADB 对我不起作用。有时重新启动我的手机会起作用,但并非总是如此,由于这个故障,我大约一周无法编程,我想我终于找到了解决方法! :-D

首先,杀死手机上运行的所有程序。拥有某种任务管理器可以使这成为一项快速任务,否则您将不得不手动一次将它们全部杀死。

如果这不能解决问题,您将需要转到手机设置,然后转到“应用程序”,然后转到“运行服务”,然后终止其中的所有服务。我正在使用 Droid Incredible,但尚未发现它对我不起作用。 :-)

所以,简短的答案是,杀死所有应用程序和所有服务。

另外,请记住,您需要关闭并重新打开 Eclipse 以查看此修复是否对您有效。我希望这对你有用,我知道它对我也有用! :-D

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

烟花易冷人易散 2024-10-04 01:28:55

当 Kindle Fire 上发生这种情况时,我只需将其关闭并重新打开即可。

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

梦幻的心爱 2024-10-04 01:28:55

我只是通过禁用和启用我的设备(索尼爱立信 Xperia)上的调试配置来修复它

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

吃兔兔 2024-10-04 01:28:55

Android 调试桥(这是用于将数据从我们的计算机发送到连接的设备,然后断开连接。我们知道,有一些层需要连接,就像 adb 本身一样,当然,最后一层是 USB 电缆,所以当您已经尝试重新启动 adb 脚本但似乎不起作用时,您只需重新连接电缆即可。

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.

絕版丫頭 2024-10-04 01:28:55

我经常在连接的设备(手机或平板电脑)甚至模拟器中看到这个问题。我注意到这个问题通常发生在一段时间不活动之后(例如午休后)。开发计算机上的操作系统可能正在尝试节省资源,而 adb 并不是那么 JIT 友好。
在 Windows 上,我必须关闭 IDE 并打开任务管理器并强制停止(终止)adb,然后重新启动 Eclipse。这总是对我有用......

  • 我注意到如果我在任务管理器中为 adb 设置更高的优先级,这个问题就会大大减少 - 尽管它仍然可能发生。

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.
Bonjour°[大白 2024-10-04 01:28:55

每当重置 USB 电缆无法解决问题时,重新启动手机也为我解决了这个问题

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

悲喜皆因你 2024-10-04 01:28:55

该解决方案可能会在您的 Android 手机上运行(在本地终端或 ssh 终端上):
$停止adbd;启动 adb

我不喜欢像重新启动手机这样过度杀伤性的解决方案...这在 Linux 下通常是不需要的。我在通过 Wifi 连接时遇到了同样的问题,所以 USB 可能根本不负责任。阅读 user655489 的答案,我想到了运行 lsof,然后运行 ​​lsof | grep adbd | 查询wc -l =>我想我打开了很多套接字,所有 FD 从 0 到 1023 都在使用中......多么可疑。

我运行了killall adbd,然后按照重新启动了adbd,我该怎么办通过 TCP 使用 ADB 连接到 Android? 问题就消失了。

原因是,至少在调试和必须终止我的不工作的应用程序时,有几个套接字永远不会关闭。

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.

來不及說愛妳 2024-10-04 01:28:55

对我有帮助的是:
++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++

如果您在 AndroidX86 上进行调试(或者以其他方式对您的 Android 开发者计算机具有 root 访问权限)
杀死“adbd”进程..并让它重新启动。

例如

[在Android VM上]

  • kill adbd(例如kill `ps a| grep adbd | awk ' { print $2 } '`)
  • /sbin/adbd将自动重新启动

[在开发站]

  • [开发站] ./adb disconnect
  • [dev station] ./adb connect

如果您没有 root,可能切换 USB 调试、重新启动等也会有所帮助。
因为它也会重新启动 adbd
++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++

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

悟红尘 2024-10-04 01:28:55

我经常遇到这个问题(我的意思是像我每次启动调试时一样)。我使用的是相当长的 USB 电缆。我换用原来的 HTC USB 线,很短,问题就消失了!

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!

伊面 2024-10-04 01:28:55

当我的 USB 线通过键盘 USB 连接到电脑时,我遇到了这个问题:O。当我直接将其连接到电脑时,我的问题解决了。

我希望这能起作用。

享受!

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!

柠檬 2024-10-04 01:28:55

根据 Maven 说明 我尝试了这个解决方案。但我遇到了同样的问题。所以我重新启动设备。它开始完美运行。

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.

玩心态 2024-10-04 01:28:55

试试这个,

禁用手机上的 USB 调试,然后在

设置 -> 下重新启用。应用->发展-> USB 调试

工作正常。

Try this,

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

Settings -> Applications -> Development -> USB debugging

its works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文