#!/usr/bin/env bash
# Build a debug Android APK for the Capacitor shell.
#
# Prerequisites (CI installs these automatically):
#   - Node.js 22 + root npm dependencies (`npm ci`)
#   - JDK 21 (JAVA_HOME)
#   - Android SDK with platform 36 + build-tools (ANDROID_SDK_ROOT / ANDROID_HOME)
#
# Output:
#   toju-app/android/app/build/outputs/apk/debug/app-debug.apk

set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

npm run bundle:rnnoise
npm run build:prod

cd toju-app
npx cap sync android

cd android
chmod +x gradlew
./gradlew assembleDebug --no-daemon --stacktrace
