Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lists connected Android devices (via adb) and the device's corresponding model and OS version - See
if [[ ! $PATH_TO_ADB ]]; then
PATH_TO_ADB=`which adb`
if [[ ! $PATH_TO_ADB ]]; then
if [[ ! $ANDROID_HOME ]]; then
echo "Failed to determine path to adb; consider setting ANDROID_HOME to your SDK directory or PATH_TO_ADB to the path to ADB"
exit 1
devices=`$PATH_TO_ADB devices | grep -E "device\$" | cut -f1`
for device in $devices; do
model=$($PATH_TO_ADB -s $device shell getprop ro.product.model | tr -d '\r')
version=$($PATH_TO_ADB -s $device shell getprop | tr -d '\r')
printf '%-20s [%6s]: %-20s \n' "$device" "$version" "$model"

This comment has been minimized.

Copy link

@SimonMarquis SimonMarquis commented Apr 10, 2014

It's sometimes convenient to have both version name and version code (aka API lvl).

sdk=$($PATH_TO_ADB -s $device shell getprop | tr -d '\r')
printf '%-20s [%5s ~ %2s]: %-20s \n' "$device" "$version" "$sdk" "$model"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment