Skip to content

Commit 12ba5a7

Browse files
ci (taskfile): fix android tasks
1 parent 63dff40 commit 12ba5a7

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

taskfiles/android.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ tasks:
104104
dev:
105105
desc: "Run on Android emulator"
106106
deps: [":npm:install", "init", "emulator:keyboard"]
107+
env:
108+
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: "0"
107109
cmds:
110+
- defer: |
111+
pkill -f "tauri android dev" 2>/dev/null || true
112+
pkill -9 -f "qemu-system-aarch64" 2>/dev/null || true
108113
- |
109114
(
110115
while ! adb devices | grep -q "emulator"; do sleep 1; done
@@ -115,15 +120,42 @@ tasks:
115120
echo "Soft keyboard auto-hidden"
116121
fi
117122
) &
118-
- cmd: cd {{.TAURI_DIR}} && npx tauri android dev "{{.ANDROID_EMULATOR}}"
123+
- cmd: cd {{.TAURI_DIR}} && npx tauri android dev "{{.ANDROID_EMULATOR}}" --host
119124
ignore_error: true
120125
interactive: true
121126
silent: true
122127

128+
run:emulator:
129+
desc: "Build release APK and install on emulator (no hot-reload, for testing)"
130+
deps: [":npm:install", "init", "emulator:keyboard"]
131+
vars:
132+
UNSIGNED_APK: "{{.TAURI_DIR}}/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk"
133+
SIGNED_APK: "{{.TAURI_DIR}}/gen/android/app/build/outputs/apk/universal/release/app-universal-release-signed.apk"
134+
DEBUG_KEYSTORE: "{{.HOME}}/.android/debug.keystore"
135+
APKSIGNER: "{{.ANDROID_HOME}}/build-tools/35.0.0/apksigner"
136+
cmds:
137+
- |
138+
# Start emulator if not running
139+
if ! adb devices | grep -q "emulator"; then
140+
echo "Starting emulator..."
141+
"{{.ANDROID_HOME}}/emulator/emulator" -avd "{{.ANDROID_EMULATOR}}" &
142+
while ! adb devices | grep -q "emulator"; do sleep 1; done
143+
adb wait-for-device
144+
sleep 5
145+
fi
146+
- cd {{.TAURI_DIR}} && npx tauri android build --apk true --aab false
147+
- |
148+
rm -f "{{.SIGNED_APK}}"
149+
"{{.APKSIGNER}}" sign --ks "{{.DEBUG_KEYSTORE}}" --ks-pass pass:android --out "{{.SIGNED_APK}}" "{{.UNSIGNED_APK}}"
150+
adb -s emulator-5554 install -r "{{.SIGNED_APK}}"
151+
adb -s emulator-5554 shell am start -n com.lunch.desktop/.MainActivity
152+
silent: true
153+
123154
dev:device:
124155
desc: "Run on physical Android device (dev mode with hot-reload)"
125156
deps: [":npm:install", "init"]
126157
cmds:
158+
- defer: pkill -f "tauri android dev" 2>/dev/null || true
127159
- cmd: cd {{.TAURI_DIR}} && npx tauri android dev --host
128160
ignore_error: true
129161
interactive: true

0 commit comments

Comments
 (0)