$ adb --help

-s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)

$ adb devices
List of devices attached 
emulator-5554   device
7f1c864e    device

$ adb shell -s 7f1c864e
error: more than one device and emulator

当前回答

在命令前使用-s选项指定设备,例如:

adb -s 7f1c864e shell

对于多个模拟器,使用进程的IP和端口作为id,例如:

adb -s 192.168.232.2:5555 <command>

参见如何获取Android模拟器的IP地址? 但如果只有一个模拟器,请尝试: Adb -e <命令>

参见http://developer.android.com/tools/help/adb.html#directingcommands

其他回答

在命令前使用-s选项指定设备,例如:

adb -s 7f1c864e shell

对于多个模拟器,使用进程的IP和端口作为id,例如:

adb -s 192.168.232.2:5555 <command>

参见如何获取Android模拟器的IP地址? 但如果只有一个模拟器,请尝试: Adb -e <命令>

参见http://developer.android.com/tools/help/adb.html#directingcommands

你可以使用它来连接你的特定设备:

   * adb devices
  --------------
    List of devices attached
    9f91cc67    offline
    emulator-5558   device

我想连接到第一个设备“9f91cc67”

* adb -s 9f91cc67 tcpip 8080
---------------------------
restarting in TCP mode port: 8080

then

* adb -s 9f91cc67 connect 192.168.1.44:8080
----------------------------------------
connected to 192.168.1.44:8080

也许这能帮到别人

Adb -d shell(或Adb -e shell)。

如果您懒得输入完整的ID,这个命令在大多数情况下都有帮助。

从http://developer.android.com/tools/help/adb.html # commandsummary:

-d -将adb命令直接到唯一连接的USB设备。当连接多个USB设备时返回错误。 -e -将adb命令直接指向唯一正在运行的模拟器。当多个模拟器正在运行时返回一个错误。

用户@janot已经在上面提到了这一点,但是这花了我一些时间来筛选最佳解决方案。

有两个广泛的用例: 1) 2个硬件连接,第一个是模拟器,另一个是设备。 处理步骤:adb -e shell....模拟器和adb -d shell....设备的任何命令。

2) n个设备(所有模拟器或手机/平板电脑)通过USB/ADB-WiFi连接: 解决方案: 这将给你当前连接的设备列表(通过USB或ADBoverWiFI) Step2)现在运行adb -s <device-id/IP-address> shell....whatever-命令 不管你有多少设备。

在连接wifi的设备上清除应用程序数据的示例ADB I将执行: Adb -s 172.16.34.89:5555 shell PM清除com.package-id

清除连接到usb设备上的应用程序数据,我将执行: Adb -s 5210d21be2a5643d shell PM清除com.package-id

在你的仿真器中安装apk:

首先获取设备列表:

-> adb devices
List of devices attached
25sdfsfb3801745eg        device
emulator-0954   device

然后在模拟器上使用-s标志安装apk:

-> adb -s "25sdfsfb3801745eg" install "C:\Users\joel.joel\Downloads\release.apk"
Performing Streamed Install
Success

附注:这里的顺序很重要,所以-s <id>必须在安装命令之前,否则它将不起作用。

希望这能帮助到一些人!