如何adb断开模拟器的连接并保持其断开连接



我已经通过ADB连接了几个Android模拟器,但我无法摆脱它们。

> 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

当我adb disconnect时,它断开了所有东西,但它们几乎立即回来(随着transport_id的增加(

当我adb kill-server然后adb devices -l时,它会重新启动adb服务器(如预期(并重新连接模拟器。我知道它从5554开始扫描偶数端口:https://developer.android.com/studio/command-line/adb#howadbworks

当我运行模拟器列表设备时,它们不会出现:

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

我想我没有在本地安装其他Android SDK Emulator套件。

杀死模拟器的正确方法是:

adb -s emulator-5554 emu kill

我设法找到了运行模拟器的进程:在windows上,使用Powershell:

> Get-Process -Id (Get-NetTCPConnection -LocalPort 5554).OwningProcess
NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
------    -----      -----     ------      --  -- -----------
134 4,074.23   1,998.07   2,544.47   12528   1 qemu-system-x86_64-headless

使用流程管理器杀死它就成功了。

最新更新