How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator"
Solution 1:
Use the -s
option BEFORE the command to specify the device, for example:
adb -s 7f1c864e shell
See also http://developer.android.com/tools/help/adb.html#directingcommands
Solution 2:
adb -d shell
(or adb -e shell
).
This command will help you in most of the cases, if you are too lazy to type the full ID.
From http://developer.android.com/tools/help/adb.html#commandsummary:
-d
- Direct an adb command to the only attached USB device. Returns an error when more than one USB device is attached.
-e
- Direct an adb command to the only running emulator. Returns an error when more than one emulator is running.
Solution 3:
Another alternative would be to set environment variable ANDROID_SERIAL to the relevant serial, here assuming you are using Windows:
set ANDROID_SERIAL=7f1c864e
echo %ANDROID_SERIAL%
"7f1c864e"
Then you can use adb.exe shell
without any issues.