@@ -129,6 +129,8 @@ tasks:
129129 desc : " Build release APK and install on emulator (no hot-reload, for testing)"
130130 deps : [":npm:install", "init", "emulator:keyboard"]
131131 vars :
132+ APK_DIR : " {{.TAURI_DIR}}/gen/android/app/build/outputs/apk/universal/release"
133+ RELEASE_APK : " {{.TAURI_DIR}}/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk"
132134 UNSIGNED_APK : " {{.TAURI_DIR}}/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk"
133135 SIGNED_APK : " {{.TAURI_DIR}}/gen/android/app/build/outputs/apk/universal/release/app-universal-release-signed.apk"
134136 DEBUG_KEYSTORE : " {{.HOME}}/.android/debug.keystore"
@@ -145,10 +147,26 @@ tasks:
145147 fi
146148 - cd {{.TAURI_DIR}} && npx tauri android build --apk true --aab false
147149 - |
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
150+ # Use already-signed release APK if available, otherwise sign unsigned APK with debug key
151+ if [ -f "{{.RELEASE_APK}}" ]; then
152+ APK="{{.RELEASE_APK}}"
153+ elif [ -f "{{.UNSIGNED_APK}}" ]; then
154+ echo "Signing unsigned APK..."
155+ rm -f "{{.SIGNED_APK}}"
156+ "{{.APKSIGNER}}" sign --ks "{{.DEBUG_KEYSTORE}}" --ks-pass pass:android --out "{{.SIGNED_APK}}" "{{.UNSIGNED_APK}}"
157+ APK="{{.SIGNED_APK}}"
158+ else
159+ echo "ERROR: No APK found in {{.APK_DIR}}"
160+ ls -la "{{.APK_DIR}}" || true
161+ exit 1
162+ fi
163+ echo "Installing APK..."
164+ if ! adb -s emulator-5554 install -r "$APK" 2>&1; then
165+ echo "Install failed, uninstalling existing app and retrying..."
166+ adb -s emulator-5554 uninstall com.lunch.app || true
167+ adb -s emulator-5554 install -r "$APK"
168+ fi
169+ adb -s emulator-5554 shell am start -n com.lunch.app/com.lunch.desktop.MainActivity
152170 silent : true
153171
154172 dev:device :
0 commit comments