Skip to content

Commit

Permalink
Fix android emulator testing (#1750)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
timtay-microsoft authored Oct 17, 2023
1 parent b39cc38 commit c6bb05a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vsts/StartEmulator.sh
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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

0 comments on commit c6bb05a

Please sign in to comment.