Those who have used the adb tool might have stumbled upon the following message :
$ adb logcat - waiting for device - error: more than one device and emulator
In such case, you need to find, then specify the device's serial like this :
$ adb devices -l List of devices attached XXX900AKC2 device usb:3-1.3 product:falcon model:XT1032 device:falcon_umts XXXBDAD913017009 device usb:1-1 product:yakju model:Nexus device:maguro $ adb logcat -s XXXBDAD913017009
Here I used the logcat command but it's the same thing when you want to install an apk or pull a file from a device.
I've just discovered that if you don't specify a serial, adb will look for an environment variable named ANDROID_SERIAL to know which device to use. If you're often using several devices in USB, you can just add the following aliases to your .bashrc file.
# ANDROID DEVICES SERIAL NUMBERS alias adb-use-galaxy-nexus='export ANDROID_SERIAL=XXXBDAD913017009' alias adb-use-moto-g='export ANDROID_SERIAL=XXX900AKC2' alias reset-android-serial='unset ANDROID_SERIAL'
When using the adb logcat command, you can also set in the ANDROID_LOG_TAGS environment variable a list of tag/severity filter, like in the following example.
# suppresses all log messages except those with the tag "ActivityManager", at priority "Info" or above, and all log messages with tag "MyApp", with priority "Debug" or above export ANDROID_LOG_TAGS="ActivityManager:I MyApp:D *:S"
These tips are fully compatible with the PidCat tool I talked about earlier.