Abish R Abish R - 1 month ago 5
Android Question

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


  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

Answer

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.