$ 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
$ 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
当前回答
当有多个设备连接时,这个要点将为你显示菜单做大部分工作:
$ adb $(android-select-device) shell
1) 02783201431feeee device 3) emulator-5554
2) 3832380FA5F30000 device 4) emulator-5556
Select the device to use, <Q> to quit:
为了避免输入,您可以创建一个别名,其中包括此处解释的设备选择。
其他回答
下面是我为自己编写的shell脚本:
#! /bin/sh
for device in `adb devices | awk '{print $1}'`; do
if [ ! "$device" = "" ] && [ ! "$device" = "List" ]
then
echo " "
echo "adb -s $device $@"
echo "------------------------------------------------------"
adb -s $device $@
fi
done
在看到“不止一个设备”错误后,我发现了这个问题,2个离线电话显示:
C:\Program Files (x86)\Android\android-sdk\android-tools>adb devices
List of devices attached
SH436WM01785 offline
SH436WM01785 offline
SH436WM01785 sideload
如果您只连接了一台设备,请执行以下命令清除离线连接:
adb kill-server
adb devices
你可以使用它来连接你的特定设备:
* 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
也许这能帮到别人
在命令前使用-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
对于Windows,这里有一个简单的例子,告诉你如何在多个设备上安装一个文件
FOR /F "skip=1" %x IN ('adb devices') DO start adb -s %x install -r myandroidapp.apk
如果您计划在批处理文件中包含此文件,请将%x替换为%%x,如下所示
FOR /F "skip=1" %%x IN ('adb devices') DO start adb -s %%x install -r myandroidapp.apk