#!/bin/bash # Deploy APK to connected Android device set -e echo "📱 Deploying to Android device..." echo "" # Check if device is connected if ! adb devices | grep -q "device$"; then echo "❌ No Android device connected!" echo "Please connect a device or start an emulator." exit 1 fi # Build type: debug or release (default: debug) BUILD_TYPE="${1:-debug}" # The debug build carries applicationIdSuffix ".debug" (see # src-tauri/android/app/build.gradle.kts), so it is a separate package and # installs alongside a release build — no uninstall dance needed. if [ "$BUILD_TYPE" = "release" ]; then APK_PATH="src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk" APP_PACKAGE="com.dtourolle.jellytau" else APK_PATH="src-tauri/gen/android/app/build/outputs/apk/universal/debug/app-universal-debug.apk" APP_PACKAGE="com.dtourolle.jellytau.debug" fi # Check if APK exists if [ ! -f "$APK_PATH" ]; then echo "❌ APK not found at: $APK_PATH" echo "Run './scripts/build-android.sh $BUILD_TYPE' first" exit 1 fi echo "📦 Installing APK: $APK_PATH" echo "📛 Package: $APP_PACKAGE" if ! adb install -r "$APK_PATH"; then echo "" echo "❌ Install failed." echo " If it says INSTALL_FAILED_UPDATE_INCOMPATIBLE, an older build of" echo " '$APP_PACKAGE' signed with a different key is still installed." echo " Uninstall just that one and retry:" echo " adb uninstall $APP_PACKAGE" exit 1 fi echo "" echo "✅ Deployment complete!" echo "🚀 Launching..." adb shell monkey -p "$APP_PACKAGE" -c android.intent.category.LAUNCHER 1 > /dev/null 2>&1 \ || echo " (auto-launch failed — start it from the launcher)"