From c6bb05abea4d8e6430e8693be32788b6932251a3 Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Tue, 17 Oct 2023 15:27:06 -0700 Subject: [PATCH] Fix android emulator testing (#1750) The old code frequently timed out waiting for the android emulator to start, but this new code makes it much more consistently successful at starting up the emulator --- vsts/StartEmulator.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vsts/StartEmulator.sh b/vsts/StartEmulator.sh index 2bdf190ff8..f9874bd503 100644 --- a/vsts/StartEmulator.sh +++ b/vsts/StartEmulator.sh @@ -1,18 +1,18 @@ #!/usr/bin/env bash echo 'Listing available android sdks for installation' -$ANDROID_HOME/tools/bin/sdkmanager --list | grep system-images +$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --list | grep system-images emulatorImage='system-images;android-28;google_apis;x86_64' avdName='Pixel_9.0' echo '' echo "Installing emulator image ${emulatorImage}" -echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install $emulatorImage +echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install $emulatorImage echo '' echo "Creating android emulator with name ${avdName}" -echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n $avdName -k $emulatorImage --force +echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n $avdName -k $emulatorImage --force echo '' echo 'Listing active android emulators' @@ -24,9 +24,9 @@ nohup $ANDROID_HOME/emulator/emulator -avd $avdName -gpu auto -no-snapshot > /de echo '' echo 'Waiting for emulator to boot up...' -$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82' -echo '' -echo "Emulator started" +nohup $ANDROID_HOME/emulator/emulator -avd $avdName -no-snapshot -no-audio -no-boot-anim -accel auto -gpu auto -qemu -lcd-density 420 > /dev/null 2>&1 & + $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done' + $ANDROID_HOME/platform-tools/adb devices echo "Emulator started" $ANDROID_HOME/platform-tools/adb devices