Quicktip: Send ADB command to all connected devices

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:

alias adb+=adb devices | tail -n +2 | cut -sf 1 | xargs -IX adb -s X

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:

adb+ install *your_debuggable.apk*

Quick and easy, isn’t it? 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.