Search code examples
androidshellcmdadbandroid-debug

How to use ADB Shell when Multiple Devices are connected? Fails with "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

Solution

  • Use the -s option BEFORE the command to specify the device, for example:

    adb -s 7f1c864e shell
    

    For multiple Emulator, use the process's IP and port as the id, like:

    adb -s 192.168.232.2:5555 <command>
    

    See How to get the Android Emulator's IP address?

    But if there is only a single Emulator, try:

    adb -e <command>
    

    See also http://developer.android.com/tools/help/adb.html#directingcommands