Use the following scripts to install apk on multiple devices/emulators.
for SERIAL in $(adb devices | grep -v List | cut -f 1);
do adb -s $SERIAL install -r /path/to/product.apk;
done
Remove -r if you are not reinstalling the apk. Also you can replace "install -r /path/to/product.apk" to other adb commands like working on one single device.
It works for me on real devices but I believe it should also works for emulators.
It is possible to issue install command simultaneously on all connected devices.
The key is to launch adb in a separate process (&).
I came up with the following script to simultaneously fire-off installation on all of the connected devices of mine and finally launch installed application on each of them:
#!/bin/sh
function install_job {
adb -s ${x[0]} install -r PATH_TO_YOUR_APK
adb -s ${x[0]} shell am start -n "com.example.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
}
#iterate over devices IP-addresses or serial numbers and start a job
while read LINE
do
eval x=($LINE)
install_job ${x[0]} > /dev/null 2>&1 &
done <<< "`adb devices | cut -sf 1`"
echo "WATING FOR INSTALLATION PROCESSES TO COMPLETE"
wait
echo "DONE INSTALLING"
Note 1: the STDOUT and STDERR are suppressed. You won't see any "adb install" operation result. This may be improved, I guess, if you really have to
Note 2: you could also improve script by providing args instead of hardcoded path and activity names.
That way you:
Don't have to manually perform install on each device
Don't have to wait for one install to finish in order to execute another one (adb tasks are launched in parallel)