Skip to content

Commit 4b511ed

Browse files
authored
chore(build): improve Android workflow (#1024)
* build: improve AVD startup time * build: bump versions * build: use built-in system image * build: use linux runner * build: enable KVM * build: use active-arch-only * build: use google repository by default
1 parent 892c36b commit 4b511ed

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

.github/workflows/android.yml

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
jobs:
1616
android-build:
17-
runs-on: macos-13 # emulator never starts on macOS 14 https://github.com/ReactiveCircus/android-emulator-runner/issues/392#issuecomment-2106167725
17+
runs-on: ubuntu-latest
1818
concurrency:
1919
group: ${{ github.ref }}-android
2020
cancel-in-progress: true
@@ -41,26 +41,47 @@ jobs:
4141
run: bun run build:android
4242
working-directory: example
4343

44+
- name: AVD cache
45+
uses: actions/cache@v4
46+
id: avd-cache
47+
with:
48+
path: |
49+
~/.android/avd/*
50+
~/.android/adb*
51+
key: avd-35-arm64-x86_64
52+
53+
- name: Enable KVM group perms
54+
run: |
55+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
56+
sudo udevadm control --reload-rules
57+
sudo udevadm trigger --name-match=kvm
58+
ls /dev/kvm
59+
4460
- name: Create AVD and generate snapshot for caching
61+
if: steps.avd-cache.outputs.cache-hit != 'true'
4562
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
4663
with:
47-
# Use the slimmer aosp_atd images for working
48-
# around "System UI isn't responding" ANR
49-
# (Application Not Responding) error
50-
#
51-
# https://android-developers.googleblog.com/2021/10/whats-new-in-scalable-automated-testing.html#:~:text=Slimmer%20Emulator%20System%20Images
52-
# https://github.com/ReactiveCircus/android-emulator-runner/issues/129
53-
# https://github.com/upleveled/hotline-bling-codealong/pull/26#issuecomment-1094659722
54-
target: aosp_atd
55-
api-level: 30
56-
arch: x86
64+
api-level: 35
65+
arch: x86_64
5766
ram-size: 4096M
58-
channel: canary
5967
profile: pixel
6068
avd-name: Pixel_3a_API_30_AOSP
6169
force-avd-creation: false
6270
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
6371
emulator-boot-timeout: 12000
6472
disable-animations: false
73+
script: echo "Generated AVD snapshot for caching."
74+
75+
- name: Run build
76+
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
77+
with:
78+
api-level: 35
79+
arch: x86_64
80+
profile: pixel
81+
avd-name: Pixel_3a_API_30_AOSP
82+
force-avd-creation: false
83+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
84+
emulator-boot-timeout: 12000
85+
disable-animations: false
6586
script: |
6687
bun example:android:release

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ buildscript {
1111
}())
1212

1313
repositories {
14-
mavenCentral()
1514
google()
15+
mavenCentral()
1616
}
1717

1818
dependencies {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"example:start": "cd example; bun start",
3333
"example:android": "cd example; bun android",
3434
"example:ios": "cd example; bun ios",
35-
"example:android:release": "cd example;react-native run-android --mode \"Release\" --appId com.pagerviewexample",
35+
"example:android:release": "cd example;react-native run-android --mode \"Release\" --appId com.pagerviewexample --active-arch-only",
3636
"example:ios:release": "cd example;react-native run-ios --mode \"Release\""
3737
},
3838
"keywords": [

0 commit comments

Comments
 (0)