Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Starts up a random AVD
#!/usr/bin/env bash
emulator=$ANDROID_HOME/tools/emulator
adb=$ANDROID_HOME/platform-tools/adb
EMULATOR_COUNT=$($emulator -list-avds | wc -l | cut -c 8)
RANDOM_INDEX=$(shuf -i 1-$EMULATOR_COUNT -n 1)
EMULATOR_NAME=$($emulator -list-avds | head -n $RANDOM_INDEX | tail -n 1)
printf "Starting $EMULATOR_NAME..."
$emulator -avd $EMULATOR_NAME > /dev/null & # Send all output to /dev/null
$adb wait-for-device
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment