$ 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
? ?
#1楼
参考:https://stackoom.com/question/zUMQ/连接多个设备时如何使用ADB-Shell-失败-错误-多个设备和模拟器
#2楼
Use the -s
option BEFORE the command to specify the device, for example: 在命令之前使用-s
选项指定设备,例如:
adb -s 7f1c864e shell
See also http://developer.android.com/tools/help/adb.html#directingcommands 另请参阅http://developer.android.com/tools/help/adb.html#directingcommands
#3楼
adb -d shell
(or adb -e shell
if you're connecting to an emulator). adb -d shell
(如果要连接到模拟器,则为adb -e shell
)。
This command will help you in most of the cases, if you are too lazy to type the full ID. 如果您懒得输入完整ID,此命令将在大多数情况下为您提供帮助。
From http://developer.android.com/tools/help/adb.html#commandsummary : 来自http://developer.android.com/tools/help/adb.html#commandsummary :
-d
- Direct an adb command to the only attached USB device.-d
- 将adb命令指向唯一连接的USB设备。 Returns an error when more than one USB device is attached. 连接多个USB设备时返回错误。
-e
- Direct an adb command to the only running emulator.-e
- 将adb命令指向唯一正在运行的模拟器。 Returns an error when more than one emulator is running. 运行多个仿真器时返回错误。
#4楼
Another alternative would be to set environment variable ANDROID_SERIAL to the relevant serial, here assuming you are using Windows: 另一种方法是将环境变量ANDROID_SERIAL设置为相关的序列,这里假设您使用的是Windows:
set ANDROID_SERIAL="7f1c864e"
echo %ANDROID_SERIAL%
"7f1c864e"
Then you can use adb.exe shell
without any issues. 然后你就可以使用adb.exe shell
而不会出现任何问题。
#5楼
I found this question after seeing the 'more than one device' error, with 2 offline phones showing: 我看到“多个设备”错误后发现了这个问题,其中有2个离线手机显示:
C:\Program Files (x86)\Android\android-sdk\android-tools>adb devices
List of devices attached
SH436WM01785 offline
SH436WM01785 offline
SH436WM01785 sideload
If you only have one device connected, run the following commands to get rid of the offline connections: 如果只连接了一个设备,请运行以下命令以消除脱机连接:
adb kill-server
adb devices
#6楼
Running adb commands on all connected devices 在所有连接的设备上运行adb命令
Create a bash (adb+) 创建一个bash(adb +)
adb devices | while read line
do
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
then
device=`echo $line | awk '{print $1}'`
echo "$device $@ ..."
adb -s $device $@
fi
done use it with 完成使用它
adb+ //+ command adb + // +命令