#!/usr/bin/env bash # Build the gallery Android APK (and optionally install it). # # ./scripts/build.sh # release x86_64 (emulator) + install # ./scripts/build.sh aarch64 # release aarch64 (real device) + install # ./scripts/build.sh debug # debug x86_64 + install (faster builds) # ./scripts/build.sh no-install # # Desktop (Linux): cargo run (needs libfontconfig1 + pkg-config) # Desktop (macOS): cargo run (pure Rust, nothing extra) set -euo pipefail cd "$(dirname "$0")/.." export ANDROID_HOME=$HOME/android-sdk export ANDROID_NDK_ROOT=$HOME/android-sdk/ndk/27.0.12077973 export PATH="$HOME/.cargo/bin:$ANDROID_HOME/platform-tools:$PATH" # Debug-keystore signing is fine for personal use / Play internal testing. export CARGO_APK_RELEASE_KEYSTORE=$HOME/.android/debug.keystore export CARGO_APK_RELEASE_KEYSTORE_PASSWORD=android arg1=${1:-x86_64} arg2=${2:-install} profile=--release case $arg1 in debug) target=x86_64-linux-android; profile="" ;; x86_64) target=x86_64-linux-android ;; aarch64) target=aarch64-linux-android ;; *) echo "unknown arch: $arg1" >&2; exit 1 ;; esac cargo apk2 build $profile --target "$target" --lib apk=$(ls target/*/apk/gallery.apk | head -1) echo "APK: $apk ($(du -h "$apk" | cut -f1))" if [ "$arg2" = install ] && command -v adb >/dev/null; then adb install -r "$apk" adb shell am start -n wow.gmp.gallery/android.app.NativeActivity || true fi