Last active
March 17, 2023 00:23
-
-
Save HQarroum/017034b8a0d75deb011df0faea433b11 to your computer and use it in GitHub Desktop.
Creates a new Android emulator and launches it in a headless mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Environment variables defining the specific Android SDK | |
# to install. | |
export API_LEVEL="${API_LEVEL:-33}" | |
export IMG_TYPE="${IMG_TYPE:-google_apis}" | |
export ARCHITECTURE=x86_64 | |
export ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-/opt/android}" | |
export DEVICE_ID="${DEVICE_ID:-pixel}" | |
export ABI="${IMG_TYPE}"/"${ARCHITECTURE}" | |
export PACKAGE_PATH="system-images;android-${API_LEVEL};${IMG_TYPE};${ARCHITECTURE}" | |
# Importing the emulator and command-line tools in the path. | |
export PATH="${PATH}:${ANDROID_SDK_ROOT}/emulator" | |
export PATH="${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin" | |
# Creating the Android Virtual Emulator. | |
echo "Creating the Android Virtual Emulator ..." | |
echo "Using package ABI '$ABI' and device '$DEVICE_ID' for creating the emulator" | |
echo no | avdmanager create avd \ | |
--force \ | |
--name android \ | |
--abi "$ABI" \ | |
--package "$PACKAGE_PATH" \ | |
--device "$DEVICE_ID" | |
# Start the emulator with no audio and no GUI. | |
echo "Starting the emulator ..." | |
emulator \ | |
-avd android \ | |
-gpu swiftshader_indirect \ | |
-no-audio \ | |
-no-window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment