Reputation: 3708
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.
Upvotes: 53
Views: 38788
Reputation: 1
Previous steps like kill server, restart Android Studio did not work for me at all. Also tried to reinstall tools.
In Run -> Run/Debug Configuration settings -> Debugger try to change Debug type: from Native Only to Java Only
Upvotes: 0
Reputation: 1
In my case running the following commands from the Terminal window (Android Studio) resolved the issue:
adb root
adb kill-server
adb start-server
Upvotes: 0
Reputation: 2752
If someone encounters the issue:
connection shut down by remote side while waiting for reply to initial handshake
start the emulator in android studio, open the terminal tab of android studio, type adb root
, this worked for me to start debugging again. Probably adb kill-server
and adb start-server
will also work.
What did not work:
Upvotes: 0
Reputation: 56
In my case, as a last resort, I had to literally factory reset the device.
I tried:
Upvotes: 0
Reputation: 1132
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
Upvotes: 0
Reputation: 356
In my case, often the reason is bad USB cable. Just replace another, better USB cable will work.
Upvotes: 0
Reputation: 721
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.
Upvotes: 5
Reputation: 63
I had to restart both my android device and android studio. That seemed to work for me.
Upvotes: 2
Reputation: 2937
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
Upvotes: 4
Reputation: 3294
For me these didnt work: Restart Android Studio,adb kill start server, restart phone.
Worked for me: Tools->Android->Disable and Enabled ADB Integration.
Upvotes: 32
Reputation: 6393
On Windows, restarting Android Studio didn't work. I instead killed the "adb.exe" process then retried.
Upvotes: 16
Reputation: 41
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.
Upvotes: 4
Reputation: 4570
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.
Upvotes: 40