Search code examples
androidandroid-emulatoradb

How do I adb disconnect an emulator and keep it disconnected?


I have somehow gotten a couple of Android emulators connected via ADB and I can't get rid of them.

> adb devices -l
List of devices attached
emulator-5554          device product:sdk_gphone_x86 model:sdk_gphone_x86 device:generic_x86_arm transport_id:1
emulator-5556          device product:sdk_gphone_x86 model:sdk_gphone_x86 device:generic_x86_arm transport_id:2

When I adb disconnect it disconnects everything, but they come back almost instantly (with an incremented transport_id)

When I adb kill-server and then adb devices -l it restarts the adb server (as expected) and reconnects the emulators. I understand that it scans the even ports from 5554 : https://developer.android.com/studio/command-line/adb#howadbworks

When I run the emulator list devices they don't appear:

> .\emulator.exe -list-avds
Nexus_5_API_30
Pixel_2_API_29_x86_64
Pixel_4a_API_30
Tablet_API_30

I don't think I've got another Android SDK Emulator suite installed locally.


Solution

  • The correct way of killing an emulator would be:

    adb -s emulator-5554 emu kill