Opening Android Emulator from terminal with global accessible shell script.
#!/bin/bash
# Change to the Android SDK directory
cd ~/Library/Android/sdk/emulator
# List the available AVDs
echo "Available AVDs:"
./emulator -list-avds
# Prompt the user to choose an AVD
echo "Enter the name of the AVD you want to launch:"
read avd_name
# Launch the chosen AVD
./emulator -avd "$avd_name"
The script will prompt you to choose an AVD from a list of available options, and then launch the selected AVD in the Android emulator. You can modify the script to include additional options or customizations as needed.
$ ./launch-android-emulator.s
Available AVDs:
Pixel_XL_API_29
Enter the name of the AVD you want to launch:
Pixel_XL_API_29
emulator: WARNING: Running on a sytem with less than 8 logical cores. Setting number of virtual cores to 1
emulator: INFO: boot completed
emulator: INFO: boot time 136746 ms
emulator: Increasing screen off timeout, logcat buffer size to 2M.
emulator: Revoking microphone permissions for Google App.h
Global access
But I want to access it globally so need to move it in user/bin.
sudo mv your-path-to/launch-android-emulator.sh /usr/local/bin/
Now launch it from anywhere in your terminal:
$ launch-android-emulator.sh