From 826483a0e13d527399accb15243d21dc0902d47e Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 27 Nov 2023 02:11:54 +0530 Subject: [PATCH] scripts/boot-emulator: update for API 26 rework --- scripts/boot-emulator.sh | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/boot-emulator.sh b/scripts/boot-emulator.sh index abd73efa..910340f1 100755 --- a/scripts/boot-emulator.sh +++ b/scripts/boot-emulator.sh @@ -1,29 +1,33 @@ #!/usr/bin/env bash -# Boots an emulator that exactly matches the one in our CI. It is recommended -# to use this as the target device for android tests. +# Creates and boots a display-less emulator (defaulting to Android 8.1, our min SDK) set -euo pipefail -[ -n "${ANDROID_SDK_ROOT:-}" ] || { - echo "ANDROID_SDK_ROOT must be set to use this script" - exit - 1 +[ -n "${ANDROID_HOME:-}" ] || { + echo "ANDROID_HOME must be set to use this script" + exit 1 } -[ -n "${ANDROID_API_LEVEL:-}" ] || { echo "ANDROID_API_LEVEL not defined; defaulting to 30"; } -API_LEVEL="${ANDROID_API_LEVEL:-30}" +[ -n "${ANDROID_API_LEVEL:-}" ] || { echo "ANDROID_API_LEVEL not defined; defaulting to 26"; } +API_LEVEL="${ANDROID_API_LEVEL:-26}" -echo no | "${ANDROID_SDK_ROOT}"/cmdline-tools/latest/bin/avdmanager create avd \ +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 \ --force \ -n "Pixel_XL_API_${API_LEVEL}" \ - --abi 'google_apis/x86' \ - --package "system-images;android-${API_LEVEL};google_apis;x86" \ + --abi "google_apis/${ARCH}" \ + --package "system-images;android-${API_LEVEL};google_apis;${ARCH}" \ --device 'pixel_xl' -"${ANDROID_SDK_ROOT}"/emulator/emulator \ +"${ANDROID_HOME}"/emulator/emulator \ -avd "Pixel_XL_API_${API_LEVEL}" \ + -gpu 'swiftshader_indirect' \ -no-window \ - -gpu swiftshader_indirect \ - -noaudio \ - -no-boot-anim + -noaudio