2021-08-16 22:44:43 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-11-26 20:41:54 +00:00
|
|
|
# Creates and boots a display-less emulator (defaulting to Android 8.1, our min SDK)
|
2021-08-16 22:44:43 +00:00
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2023-11-26 20:41:54 +00:00
|
|
|
[ -n "${ANDROID_HOME:-}" ] || {
|
|
|
|
echo "ANDROID_HOME must be set to use this script"
|
|
|
|
exit 1
|
2021-08-16 22:44:43 +00:00
|
|
|
}
|
|
|
|
|
2023-11-26 20:41:54 +00:00
|
|
|
[ -n "${ANDROID_API_LEVEL:-}" ] || { echo "ANDROID_API_LEVEL not defined; defaulting to 26"; }
|
|
|
|
API_LEVEL="${ANDROID_API_LEVEL:-26}"
|
2021-08-16 22:44:43 +00:00
|
|
|
|
2023-11-26 20:41:54 +00:00
|
|
|
ARCH="x86_64"
|
|
|
|
if [[ "$(uname -m)" == "arm64" && "$(uname)" == "Darwin" ]]; then
|
|
|
|
ARCH="arm64-v8a"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sdkmanager "system-images;android-${API_LEVEL};google_apis;${ARCH}"
|
|
|
|
|
|
|
|
echo no | "${ANDROID_HOME}"/cmdline-tools/latest/bin/avdmanager create avd \
|
2021-08-16 22:44:43 +00:00
|
|
|
--force \
|
|
|
|
-n "Pixel_XL_API_${API_LEVEL}" \
|
2023-11-26 20:41:54 +00:00
|
|
|
--abi "google_apis/${ARCH}" \
|
|
|
|
--package "system-images;android-${API_LEVEL};google_apis;${ARCH}" \
|
2021-08-16 22:44:43 +00:00
|
|
|
--device 'pixel_xl'
|
|
|
|
|
2023-11-26 20:41:54 +00:00
|
|
|
"${ANDROID_HOME}"/emulator/emulator \
|
2021-08-16 22:44:43 +00:00
|
|
|
-avd "Pixel_XL_API_${API_LEVEL}" \
|
2023-11-26 20:41:54 +00:00
|
|
|
-gpu 'swiftshader_indirect' \
|
2021-08-16 22:44:43 +00:00
|
|
|
-no-window \
|
2023-11-26 20:41:54 +00:00
|
|
|
-noaudio
|