Android Studio Debugger Port Error - "handshake failed - connection prematurely closed"
Android StudioAndroid Studio Problem Overview
When I try to attach the Android Studio Debugger to a process, I get the following error:
Error running Android Debugger (8603):
Unable to open debugger port (localhost:8603): java.io.IOException "handshake failed - connection prematurally closed"
Kudos to whoever spelled prematurely that way. Anyway, how do I get around this problem?
I'm using Android Studio 1.2.2 on Ubuntu. This did not help.
Android Studio Solutions
Solution 1 - Android Studio
The best and one solution for me was just to restart Android Studio.
Before I tried to restart adb server from command prompt or disable and enable adb integration from tools->Android->Check/Unchek the line, unplug and plug device , but nothing helped.
Solution 2 - Android Studio
For me these didnt work: Restart Android Studio,adb kill start server, restart phone.
Worked for me: Tools->Android->Disable and Enabled ADB Integration.
Solution 3 - Android Studio
On Windows, restarting Android Studio didn't work. I instead killed the "adb.exe" process then retried.
Solution 4 - Android Studio
I didn't need to restart my device, only restarting android studio fixed it ( clean your project if needed).
If doesn't work then restart your device.
Solution 5 - Android Studio
Maybe you should consider retaining only one device or a emulator, because Android Studio or Intellij IDEA only accept one device or emulator when debugging. It works well for me. I hope this can help.
Solution 6 - Android Studio
Restarting the ADB server worked for me:
$ adb kill-server
$ adb start-server
* daemon not running. starting it now at tcp:5037 *
* daemon started successfully *
$ adb devices
List of devices attached
ce0217127216c0220c device
Solution 7 - Android Studio
I had to restart both my android device and android studio. That seemed to work for me.
Solution 8 - Android Studio
In my case, often the reason is bad USB cable. Just replace another, better USB cable will work.
Solution 9 - Android Studio
It shows that your previous debbugger was not closed. You should click stop (red button) to stop your attach previously, and rerun your debbugger. It would attach again