Skip to content

Instantly share code, notes, and snippets.

@hidroh
Last active May 3, 2024 03:58
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save hidroh/67b2ee7bbdd9038450c00d8a4d69c3fa to your computer and use it in GitHub Desktop.
Save hidroh/67b2ee7bbdd9038450c00d8a4d69c3fa to your computer and use it in GitHub Desktop.
Handy bash script to prompt for an Android virtual device (AVD) selection and launch it. Assuming that Android SDK has been set up and is in user PATH.
emulator -list-avds | cat -n
printf "Select AVD: "
read index
avd=$(emulator -list-avds | sed "${index}q;d")
echo "Selected $avd"
emulator -netdelay none -netspeed full -avd $avd
@Natsume150
Copy link

how to use this? :s

@p32929
Copy link

p32929 commented Mar 13, 2017

Thank you so much...

@MouseZero
Copy link

I found this to work for me. If you don't want to add Android SDK to your path. I also added "&disown &exit" to close the terminal window without closing the emulator.

  cd $HOME/Android/Sdk/tools
  emulator -list-avds | cat -n
  printf "Select AVD: "
  read index
  avd=$(emulator -list-avds | sed "${index}q;d")
  echo "Selected $avd"
  emulator -netdelay none -netspeed full -avd $avd &disown &exit

@MouseZero
Copy link

Thanks for posting this it was very helpful!

@mhnnunes
Copy link

Thanks! This helped a lot!

@vinay-vissh
Copy link

Thanks @hidroh for the original script and @MouseZero for the modified script :)

Copy link

ghost commented Mar 6, 2018

it's work for me perfectly, so thanks for your code.

@alexjorgef
Copy link

pushd ${ANDROID_HOME}/tools
./emulator -list-avds | cat -n
printf "Select AVD: "
read index
avd=$(emulator -list-avds | sed "${index}q;d")
echo "Selected $avd"
./emulator -netdelay none -netspeed full -avd $avd
popd

@enieber
Copy link

enieber commented Jul 20, 2018

I need change your code @Alex1a

pushd ${ANDROID_HOME}/tools
./emulator -list-avds | cat -n
printf "Select AVD: "
read index
avd=$(./emulator -list-avds | sed "${index}q;d")
echo "Selected $avd"
./emulator -netdelay none -netspeed full -avd $avd
popd

@enieber
Copy link

enieber commented Jul 20, 2018

I create a project in Github for maintainer my modification of script, thanks to @Alex1a and @hidroh

@Under-Warz
Copy link

Thank's !

@R3oLoN
Copy link

R3oLoN commented Oct 15, 2018

Thank's !

@enieber
Copy link

enieber commented Feb 5, 2020

now the Open Avd is support to Windows, Linux and MacOS

@ricardopereira
Copy link

ricardopereira commented Nov 16, 2023

I was facing an issue while running the script: "Could not launch '/Users/<redacted>/Library/Android/sdk/tools/../emulator/qemu/darwin-x86_64/qemu-system-aarch64': No such file or directory". I'm using macOS.

Then I found out that recent versions of the Android SDK, the emulator tool has been moved out of the tools directory to its own emulator directory at the same level as tools. I had to modify the script to navigate to ${ANDROID_HOME}/emulator instead of ${ANDROID_HOME}/tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment