Android adb "Unable to open sync connection!" - android

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?

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
Click Revoke USB debugging authorizations.
Click OK.
Reattach USB.
Click OK for Permissions.

Related

Android Studio: java.io.IOException: An existing connection was forcibly closed by the remote host

I read many posts to fix this problem. None worked for me.
Error:
Target device: lenovo-lenovo_a6000-89a70dc9
Installing APK: C:\Users\Nikhil\AndroidStudioProjects\ProfitKey\app\build\outputs\apk\app-debug.apk
Uploading file to: /data/local/tmp/helix.profitkey.hotelapp
java.io.IOException: An existing connection was forcibly closed by the remote host
I tried below
Kill and start adb
Invalidate and restart android studio
Removed adb process in the taskbar
Restarted the device and pc
Restarted studio, clean and rebuild
Taskbar have only one adb.exe
Updated the driver from device manager
Another device it is working. But previously both device worked fine for me.
Target device: motorola-xt1022-ZX1B33PRVP
Installing APK: C:\Users\Nikhil\AndroidStudioProjects\ProfitKey\app\build\outputs\apk\app-debug.apk
Uploading file to: /data/local/tmp/helix.profitkey.hotelapp
Installing helix.profitkey.hotelapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/helix.profitkey.hotelapp"
pkg: /data/local/tmp/helix.profitkey.hotelapp
Success
Edited:
I tried with two lenovo A6000. One is working and another is not working. Then, Moto is working and samsung galaxy is not working. Whenever I am killing and starting the adb. The task manager creating two adb first and after few seconds one was hiding. Was this a problem? But still some devices working fine.
adb starts automatically after killing by command or from the task manager if android studio is opened.
Now working for all the devices. Just I uninstalled the driver of mobile in PC and changed the port to connect with that device. I think some problem with the port in my PC. After long research it fixed by a small thing. It might be helpful to someone.
I also faced same problem,this was a just port problem,I was using computer front USB port ,just use computer back USB port and problem solved.
Restarting adb.exe worked for me. (For windows, Just Go to taskManager and kills the adb.exe process and re-deploy)
I also faced same problem, just change computer USB port and problem solved. or use genymotion emulator
I closed my virtual devices, opened windows task manager, and killed all adb.exe tasks -- there was one constant one and another that would appear then disappear. Aftwerwards, i started my virtual device and everything worked again.
Make sure that no other program is trying to take control of the ADB. You can check this by opening task manager, right clicking on any of the adb.exe, and opening the file location. Turns out that my HTC sync manager had it's own ADB and wanted to run it all the time. I uninstalled the program and haven't had issues since.
In my case, I had to change the USB debugging cable.

Android adb stop working

Until yesterday everything was working perfect until today that I connected my phone (just updated to Jelly Bean) and adb.exe stop working. If I execute adb.exe I can see the help but when I want to use any command it just run forever and no message is shown.
I tried with "kill-server" and "devices" and it runs forever, no message at all is displayed and I must terminate the process to close it.
I just connect the same phone to other PC that was fully functional and also adb.exe stop working. The strange thing is that adb.exe will not work any more even If I disconnect the phone and/or I connect my tablet. Adb.exe just got useless.
I was using the same phone yesterday (android 4.0), with my tablet (android 4.2) and adb.exe was working.
Adb.exe is not corrupted as I checked it MD5 and it is the same as in working pc (5787e5df1a68e7afea82d58e5f0d6549 *adb.exe).
I have Android Debug Bridge version 1.0.31 and Android SDK tools 22. I uninstalled android sdk tools and Installed again but when is near to finish it hangs because it launches adb.exe and again it will run forever.
Please any suggestion or help?
Try rebooting. Sometimes the USB drivers lock up. I work HEAVILY with ADB in my project at http://android-casual.googlecode.com and I find it to be one of three things when ADB locks up.. 1. USB drivers, or 2. adb_usb.ini needs an update, or 3. on new devices you have to "pair" them so that ADB can perform any action.
To pair, you can disconnect, reconnect and run "adb devies" to display the pairing on the device.
Not sure if you're still facing this issue, but for what it's worth I had the same kind of issue with adb.exe, and came across this post while trying to troubleshoot it. In my case, I wasn't using any physical Android devices, only the Emulator. Everything had been working fine and then suddenly adb.exe would no longer respond (couldn't get any output from any adb command - it just appeared to hang).
In the end, my issue turned out to be another application I had installed on my development machine. It was starting as a service, and was listening on the exact same port that the adb server runs on (5037), which appeared to be confusing it. Once I changed the application to use a different port, adb started working again and everything was fine.
Run command
where adb
I had such kind of situation.
In my case
where adb
gave output
C:\Windows\adb.exe
D:\AndroidSDK\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe
I tried to run adb from disk C, when Eclipse used second adb from AndroidSDK (from disk D).
I removed adb from strange path C:\Windows\adb.exe, and this solved this problem.
I got the same problem,my solution is going to cmd and paste adb.exe path,and then click enter button.For example
D:\Android\Android\platform-tools\adb.exe

android: Failed to install .apk on device "device": timeout

A few days ago I started having troubles while trying to install a .apk on my Galaxy S2. I select my phone as the target, click OK and in the Console get the following error:
Failed to install AvatarRun.apk on device 'device number': timeout
Launch canceled!
Without changing anything in code and running again I can also get the error:
Failed to install AvatarRun.apk on device 'device number': device not
found com.android.ddmlib.InstallException: device not found Launch
canceled!
I have tried opening a command window and navigating to android-sdk\platform-tools and running:
adb kill-server adb start-server
This did not fix the issue.
This seems to just be a coincidence, but after failing many times I changed the minimum SDK in the Manifest from 10 to 7 and the .apk loaded on the next try, but has worked intermitently since and generates the same errors.
Can anyone suggest a method for finding what is causing this error?
After trying the fixes mentioned above, I ended up installing and reinstalling the Galaxy drivers. This didn't help. What eventually worked (so far) was to switch which USB port the Galaxy is plugged into. Once I did this everything was functioning as it should.
It may sound ridiculous, I tried all the ways suggested in Android error: Failed to install *.apk on device *: timeout
None of them works for me except unplugging the current cable and change for a new one.
There are various solutions:
Try changing the ADB connection timeout. The default is 5000; you should change it to 10000ms or so.
Window -> Preferences -> Android -> DDMS -> ADB Connection Timeout (ms)
Try to unplug and re-plug the cable. It seems that sometimes Eclipse loses the connection with Device. Sometimes you just need to plug into other USB port.
You might need to kill the ADB process and restart it.
adb kill-server and then
adb start-server
For me, the solution is to uninstall the old apk from the phone.
This problem often shows up if the computer is not fast enough. So,if you go to task manager you will see the performance. If you are watching video or running other programs at the same time while you are running your android application close other programs; at least during installing the app on device or emulator. You might even need to close internet browser.
You might need to update your computer to make it faster if you can.
Hope this helps someone:)

Constantly getting ...DeviceMonitor] Failed to start monitoring

I find that after running or debugging my application a few times using eclipse, that I get the above output in my console (in red) and I get no feedback from Dalvik as to the connection status to my phone is going. My application will still debug etc. I just get nothing useful in my Console.
Any ideas how to fix this? It appears intermittent. It starts doing it after a few minutes, continues to do it for quite a while and occasionally goes away again. This has happened on my last laptop and now on my new laptop with a completely fresh install etc.
I'm on Windows 7 64 bit; but maybe 2 or 3 times during the day I get this same error. I tried the reboot thing, which sometimes worked, sometimes didn't.
I have found the fix to be:
Close Eclipse
Unplug USB
Open task manager and find the "adb.exe *32" and End Task
Open Eclipse (not done yet)
"Clean All" (not just project)
Then build the project (for me, just building the project works)
Plug USB back in and there ya go!
Always works for me. If anyone knows of an update to something I can download to avoid doing this all the time, I'd love to know!
I had the same problem -
Try to use a different USB port.
From my experience, the USB connections on the PC front are not recommended.
Year almost 2018 I just had same problem which doubled my gray hairs. It turned out my test phone Samsung Galaxy S6 does not like the USB ports on my Apple Thunderbolt Display. I just plugged the USB cable directly to my Mac Pro and it worked right away. Funny thing is my Google Pixel Phone never complains about the USB port on Thunderbolt.
To keep the error message from showing up I did the following on Eclipse 3.7:
Window->Preferences
On the left side tree select Android->DDMS
In the DDMS settings window choose logging level "Assert"
Click "Apply"
You may have to kill the deamon and restart it. Following are the steps;
open a command prompt and locate the SDK's platform tools folder. E.g.:- cd c:\android-sdk-windows\platform-tools
then execute "adb kill-server" command. You will see the disconnected icon in run configuration panel is now cleared.
then again execute "adb start-server" command.
Then try running the device, if it doesn't work try restarting the eclipse.
restart your dev machine, worked for me :)
I was using a USB 3.0 port too and a device Xoom with ics 4.0.
To solve my problem, I needed to restart my Windows, because in the DDMS my device was showed twice.
After the restart, I needed to change the USB port to a 2.0 USB port and it work for me.
problem causes bay USB bug
1- save your work
2- Close Eclipse
3- restart your computer
4- Open Eclipse and enjoy ^^
it works for me
good luck

when I run project this kind of error occurs

LogCat shows this error,
[2011-05-05 08:57:54 - test] Failed to install test.apk on device 'emulator-5554': timeout
[2011-05-05 08:57:54 - test] Launch canceled!
How about changing adb connection timeout. it's default is 5000 ms.
Window -> Preferences -> Android -> DDMS -> ADB connection timeout to 10000 ms
c:
cd\
cd C:\android\platform-tools
adb kill-server
adb start-server
copy the above in a notepad and save it as "ADB_restart.bat". Run it when you get this error.
Will probably fix the error. This also fixes lot of connection problems with devices and emulators.
Also as suggested by HERO, Do increase
your Timeout.
I have noticed that a combination of either restarting eclipse, or the phone/emulator, or both has proven effective in rectifying adb disconnects in many cases... I've never had luck with restarting adb after a disconnect personally
Try closing eclipse and reopening. You might get some warning when it opens something along of the lines of a marker not found but generally everything is still ok.
I had this problem with ADB (Android Debug Bridge) using an ethernet connection. The USB to ethernet adapter was quite old, using a newer one with a MOSCHIP chipset solved the problem.
Dont worry too much about it ... just look at the active emulators when this repeats again... It mostly is the Emulator not being registered as something that is active. Close the already running emulator and then restart it. you must be just fine...
Rajesh

Categories

Resources