2022-11-29 12:16:28 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-06-02 18:15:21 -04:00
|
|
|
UNAME_M=${1-$(uname -m)}
|
2022-11-29 12:16:28 -05:00
|
|
|
if [[ "$UNAME_M" == "arm64" ]]; then
|
|
|
|
ANDROID_ABI=arm64-v8a
|
|
|
|
elif [[ "$UNAME_M" == "x86_64" ]]; then
|
|
|
|
ANDROID_ABI=x86
|
|
|
|
else
|
|
|
|
echo "Unknown platform"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
AVD_NAME="testavd"
|
|
|
|
AVD_TAG="google_atd"
|
|
|
|
AVD_IMAGE="system-images;android-30;$AVD_TAG;$ANDROID_ABI"
|
|
|
|
AVD_DEVICE="Nexus 10"
|
2023-09-01 15:36:38 -04:00
|
|
|
|
2024-06-02 18:15:21 -04:00
|
|
|
SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
|
|
|
|
AVDMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager
|
2023-09-01 15:36:38 -04:00
|
|
|
if ! command -v $SDKMANAGER; then
|
2024-06-02 18:15:21 -04:00
|
|
|
echo "Can't find 'sdkmanager' in the usual places."
|
|
|
|
exit
|
2023-09-01 15:36:38 -04:00
|
|
|
fi
|
2024-06-02 18:15:21 -04:00
|
|
|
|
2023-11-12 16:47:17 -05:00
|
|
|
EMULATOR=$ANDROID_HOME/emulator/emulator
|
2023-09-01 15:36:38 -04:00
|
|
|
if ! command -v $EMULATOR; then
|
|
|
|
echo "Can't find 'emulator' in the usual places."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-11-29 12:16:28 -05:00
|
|
|
# Install AVD image
|
2023-09-01 15:36:38 -04:00
|
|
|
$SDKMANAGER --install "$AVD_IMAGE"
|
2022-11-29 12:16:28 -05:00
|
|
|
# Make AVD
|
2023-09-01 15:36:38 -04:00
|
|
|
echo "no" | $AVDMANAGER --verbose create avd --force --name "$AVD_NAME" --package "$AVD_IMAGE" --tag "$AVD_TAG" --abi "$ANDROID_ABI" --device "$AVD_DEVICE"
|
2022-11-29 12:16:28 -05:00
|
|
|
# Run emulator
|
2023-11-12 16:47:17 -05:00
|
|
|
$ANDROID_HOME/emulator/emulator -avd testavd -no-snapshot -no-boot-anim -no-window &
|
2022-11-29 12:16:28 -05:00
|
|
|
( trap exit SIGINT ; read -r -d '' _ </dev/tty ) ## wait for Ctrl-C
|
|
|
|
kill %1
|
|
|
|
wait
|