$ 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
当前回答
下面是我为自己编写的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
其他回答
另一种方法是将环境变量ANDROID_SERIAL设置为相关的串行,这里假设你使用的是Windows:
set ANDROID_SERIAL=7f1c864e
echo %ANDROID_SERIAL%
"7f1c864e"
然后你可以使用adb.exe shell没有任何问题。
在看到“不止一个设备”错误后,我发现了这个问题,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
下面是我为自己编写的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
在任何特定设备上运行shell的最佳方式是使用:
adb -s << emulator UDID >> shell
For Example:
adb -s emulator-5554 shell
在所有连接的设备上运行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
完成 使用它
adb+//+命令