Skip to content

Commit ae2bd53

Browse files
fix: emulator start
1 parent b957087 commit ae2bd53

1 file changed

Lines changed: 56 additions & 24 deletions

File tree

.github/workflows/e2e-android.yml

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,37 +39,69 @@ jobs:
3939
java-version: '17'
4040
distribution: 'zulu'
4141
cache: 'gradle'
42-
- name: Set up Android SDK
43-
uses: android-actions/setup-android@v3
44-
45-
- name: Install system image
42+
- name: Install NDK
43+
uses: nttld/setup-ndk@v1
44+
id: setup-ndk
45+
with:
46+
ndk-version: r26d
47+
local-cache: true
48+
- name: Set ANDROID_NDK
49+
run: echo "ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}" >> $GITHUB_ENV
50+
- name: Cache SDK image
51+
id: cache-sdk-img
52+
uses: actions/cache@v3
53+
with:
54+
path: $ANDROID_HOME/system-images/
55+
key: ${{ runner.os }}-build-system-images-${{ env.SYSTEM_IMAGES }}
56+
- name: SKDs - download required images
57+
if: ${{ steps.cache-sdk-img.outputs.cache-hit != 'true' }}
58+
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-34;google_apis;x86_64"
59+
- name: Cache AVD
60+
id: cache-avd
61+
uses: actions/cache@v3
62+
with:
63+
path: ~/.android/avd/${{ env.AVD_NAME }}.avd
64+
key: ${{ runner.os }}-avd-images-${{ env.SYSTEM_IMAGES }}-${{ env.AVD_NAME }}
65+
- name: Emulator - Create
66+
if: ${{ steps.cache-avd.outputs.cache-hit != 'true' }}
4667
run: |
47-
sdkmanager --install "system-images;android-34;google_apis;x86_64"
48-
sdkmanager --install "emulator"
49-
sdkmanager --licenses <<< "y"
50-
51-
- name: Create AVD
68+
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd \
69+
-n ${{ env.AVD_NAME }} \
70+
-k "system-images;android-34;google_apis;x86_64" \
71+
--device "pixel_6" \
72+
--sdcard 512M \
73+
--force
74+
- name: Emulator - Set screen settings
75+
if: ${{ steps.cache-avd.outputs.cache-hit != 'true' }}
5276
run: |
53-
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n test-avd -k "system-images;android-34;google_apis;x86_64" --device "pixel_6"
54-
mkdir -p ~/.android/avd
55-
echo "hw.gpu.mode=swiftshader_indirect" >> ~/.android/avd/test-avd.avd/config.ini
56-
echo "hw.gpu.enabled=yes" >> ~/.android/avd/test-avd.avd/config.ini
57-
58-
- name: Start emulator
77+
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager list avd
78+
# CONFIG="$HOME/.android/avd/${{ env.AVD_NAME }}.avd/config.ini"
79+
# if [ -f "$CONFIG" ]; then
80+
# sed -i 's/.*hw\.lcd\.density.*/hw\.lcd\.density = 480/g' "$CONFIG"
81+
# sed -i 's/.*hw\.lcd\.width.*/hw\.lcd\.width = 1344/g' "$CONFIG"
82+
# sed -i 's/.*hw\.lcd\.height.*/hw\.lcd\.height = 2992/g' "$CONFIG"
83+
# else
84+
# echo "ERROR: $CONFIG not found"
85+
# exit 1
86+
# fi
87+
- name: Symlink AVD directory
5988
run: |
60-
$ANDROID_HOME/emulator/emulator -avd test-avd -no-window -no-audio -no-boot-anim -accel off -memory 2048 -gpu swiftshader_indirect &
61-
sleep 5
89+
mkdir -p $HOME/.android
90+
ln -s /home/runner/.config/.android/avd $HOME/.android/avd
91+
92+
- name: Emulator - Boot
93+
run: $ANDROID_HOME/emulator/emulator -memory 4096 -avd ${{ env.AVD_NAME }} -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -accel off &
6294

63-
- name: Wait for emulator to boot
95+
- name: ADB Wait For Device
6496
run: |
65-
adb wait-for-device
66-
boot_completed=""
67-
until [[ "$boot_completed" == "1" ]]; do
97+
$ANDROID_HOME/platform-tools/adb devices -l
98+
$ANDROID_HOME/platform-tools/adb wait-for-device
99+
until $ANDROID_HOME/platform-tools/adb shell getprop sys.boot_completed | grep -m 1 '1'; do
100+
echo "Waiting for emulator to boot..."
68101
sleep 5
69-
boot_completed=$(adb shell getprop sys.boot_completed | tr -d '\r')
70-
echo "Waiting for emulator to boot... ($boot_completed)"
71102
done
72-
echo "✅ Emulator booted and ready!"
103+
echo "✅ Emulator booted."
104+
timeout-minutes: 10
73105

74106
- name: Reverse TCP
75107
working-directory: apps/${{ env.WORKING_DIRECTORY }}

0 commit comments

Comments
 (0)