$ 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命令
创建一个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+//+命令
其他回答
在命令前使用-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 -d shell(或Adb -e shell)。
如果您懒得输入完整的ID,这个命令在大多数情况下都有帮助。
从http://developer.android.com/tools/help/adb.html # commandsummary:
-d -将adb命令直接到唯一连接的USB设备。当连接多个USB设备时返回错误。 -e -将adb命令直接指向唯一正在运行的模拟器。当多个模拟器正在运行时返回一个错误。
当有多个设备连接时,这个要点将为你显示菜单做大部分工作:
$ 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:
为了避免输入,您可以创建一个别名,其中包括此处解释的设备选择。
在你的仿真器中安装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>必须在安装命令之前,否则它将不起作用。
希望这能帮助到一些人!
在所有连接的设备上运行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+//+命令