Skip to content

Instantly share code, notes, and snippets.

@hidroh
Last active November 28, 2024 13:26
Show Gist options
  • Select an option

  • Save hidroh/67b2ee7bbdd9038450c00d8a4d69c3fa to your computer and use it in GitHub Desktop.

Select an option

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
@p32929

p32929 commented Mar 13, 2017

Copy link
Copy Markdown

Thank you so much...

@h-cow

h-cow commented Mar 15, 2017

Copy link
Copy Markdown

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

@h-cow

h-cow commented Mar 15, 2017

Copy link
Copy Markdown

Thanks for posting this it was very helpful!

@mhnnunes

Copy link
Copy Markdown

Thanks! This helped a lot!

@vinay-vissh

Copy link
Copy Markdown

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

ghost commented Mar 6, 2018

Copy link
Copy Markdown

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

@alexjorgef

Copy link
Copy Markdown
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

enieber commented Jul 20, 2018

Copy link
Copy Markdown

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

enieber commented Jul 20, 2018

Copy link
Copy Markdown

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

@Under-Warz

Copy link
Copy Markdown

Thank's !

@R3oLoN

R3oLoN commented Oct 15, 2018

Copy link
Copy Markdown

Thank's !

@enieber

enieber commented Feb 5, 2020

Copy link
Copy Markdown

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

@ricardopereira

ricardopereira commented Nov 16, 2023

Copy link
Copy Markdown

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