Quicktip: Send ADB command to all connected devices
August 08, 2017
When a bug in your Android app is hard to reproduce, it can make sense to install a debuggable version of your app on more than one device. Some helpful folks shared an easy way to adb install
to all connected devices with just one command on stackoverflow. Based on that I created the following alias: [code lang=text] alias adb+=adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb -s X [/code] This performs an adb devices
, starts to read from the output’s 2nd line, gets the serial number in each line and for each line builds the command adb -s *serial number*
. For a full explanation you can check out that command on a web site I find quite useful: explainshell With that alias in place you can now install your app to all connected devices that show up in adb devices
with nothing more than this: [code lang=text] adb+ install *your_debuggable.apk* [/code] Quick and easy, isn’t it? :-)