@@ -80,30 +80,49 @@ jobs:
8080 - name : Setup Android SDK
8181 uses : android-actions/setup-android@v3
8282
83- - name : Increase VM Performance
83+ - name : Install system image
84+ run : sdkmanager "system-images;android-29;google_apis;x86"
85+
86+ - name : Create AVD
87+ run : |
88+ echo "no" | avdmanager create avd -n test -k "system-images;android-29;google_apis;x86" --device "pixel"
89+ avdmanager list avd
90+
91+ - name : Start Emulator
92+ run : |
93+ $ANDROID_HOME/emulator/emulator -avd test -no-snapshot-save -no-window -no-audio -gpu swiftshader_indirect -no-boot-anim &
94+ echo $! > emulator.pid
95+
96+ - name : Wait for Emulator to Boot
8497 run : |
85- echo "Installing KVM acceleration tools"
86- sudo apt-get update
87- sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
98+ echo "Waiting for emulator to start..."
99+ adb wait-for-device
100+
101+ boot_completed=""
102+ until [ "$boot_completed" = "1" ]; do
103+ sleep 5
104+ boot_completed=$(adb shell getprop sys.boot_completed | tr -d '\r')
105+ echo "Waiting... boot_completed=$boot_completed"
106+ done
107+
108+ until adb shell pm list packages > /dev/null 2>&1; do
109+ echo "Waiting for package manager to become available..."
110+ sleep 5
111+ done
112+
113+ echo "Emulator is ready."
88114
89115 - name : Run Instrumentation Tests
90- uses : reactivecircus/android-emulator-runner@v2
91- with :
92- api-level : 29
93- target : google_apis
94- profile : pixel
95- emulator-options : " -no-window -no-audio -gpu swiftshader_indirect -no-boot-anim"
96- disable-animations : true
97- script : |
98- adb wait-for-device
99- boot_completed=""
100- while [ "$boot_completed" != "1" ]; do
101- sleep 5
102- boot_completed=$(adb shell getprop sys.boot_completed | tr -d '\r')
103- echo "Waiting for emulator... (boot_completed=$boot_completed)"
104- done
105- echo "Emulator ready!"
106- ./gradlew connectedCheck --build-cache --parallel
116+ run : ./gradlew connectedCheck --build-cache --parallel
117+
118+ - name : Kill Emulator
119+ if : always()
120+ run : |
121+ if [ -f emulator.pid ]; then
122+ EMULATOR_PID=$(cat emulator.pid)
123+ echo "Killing emulator with PID $EMULATOR_PID"
124+ kill $EMULATOR_PID || true
125+ fi
107126
108127 build-release :
109128 name : Build APK & AAB
0 commit comments