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

Exception or error:

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

  1. Kill and start adb
  2. Invalidate and restart android studio
  3. Removed adb process in the taskbar
  4. Restarted the device and pc
  5. Restarted studio, clean and rebuild
  6. Taskbar have only one adb.exe
  7. 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.

enter image description here

How to solve:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *