Have you ever had multiple emulators or physical devices or a combination of the two attached at once? It’s frustrating to shut off or unplug your devices in order to single out the one that needs to be targeted. Look no further, adb includes a command line switch to choose the specific device you want to target.
Let’s begin by listing our currently attached devices.
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
HT09PR217646 device
As you can see, we have three devices attached to our system. Two emulators and one physical phone. Now let’s logcat our physical device because it’s running our application that we want to debug. Just pass the -d switch to adb to target our device.
$ adb -d logcat
If we had a single emulator instance and one or more physical devices attached we could pass in the -e switch to adb which targets emulator.
$ adb -e logcat
The final switch we can use for device targeting is the -s switch, which stands for serial number.
$ adb -s emulator-5554 logcat
$ adb -s emulator-5556 logcat
$ adb -s HT09PR217646 logcat