-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathbuild-android.sh
More file actions
executable file
·62 lines (51 loc) · 1.67 KB
/
Copy pathbuild-android.sh
File metadata and controls
executable file
·62 lines (51 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
# ── Prerequisites check ──
for cmd in rustup npm npx java; do
command -v "$cmd" >/dev/null || { echo "Missing: $cmd"; exit 1; }
done
if [ -z "${ANDROID_HOME:-}" ] && [ -z "${ANDROID_SDK_ROOT:-}" ]; then
# Common default paths
if [ -d "$HOME/Library/Android/sdk" ]; then
export ANDROID_HOME="$HOME/Library/Android/sdk"
elif [ -d "$HOME/Android/Sdk" ]; then
export ANDROID_HOME="$HOME/Android/Sdk"
else
echo "Error: ANDROID_HOME not set and SDK not found in default locations."
exit 1
fi
fi
export ANDROID_SDK_ROOT="${ANDROID_HOME:-$ANDROID_SDK_ROOT}"
export NDK_HOME="${NDK_HOME:-$ANDROID_SDK_ROOT/ndk/$(ls "$ANDROID_SDK_ROOT/ndk/" 2>/dev/null | sort -V | tail -1)}"
if [ ! -d "$NDK_HOME" ]; then
echo "Error: NDK not found at $NDK_HOME"
echo "Install via: sdkmanager --install 'ndk;27.0.12077973'"
exit 1
fi
echo "SDK: $ANDROID_SDK_ROOT"
echo "NDK: $NDK_HOME"
# ── Rust Android targets ──
TARGETS=(aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android)
for t in "${TARGETS[@]}"; do
rustup target add "$t" 2>/dev/null || true
done
echo "=== 1. npm install ==="
npm ci
echo "=== 2. Build Tauri Android (APK) ==="
npx tauri android build
echo "=== Done ==="
echo ""
# Find output APKs
APK_DIR="src-tauri/gen/android/app/build/outputs/apk"
if [ -d "$APK_DIR" ]; then
echo "APKs:"
find "$APK_DIR" -name "*.apk" -exec ls -lh {} \;
fi
# Find output AABs
AAB_DIR="src-tauri/gen/android/app/build/outputs/bundle"
if [ -d "$AAB_DIR" ]; then
echo ""
echo "AABs:"
find "$AAB_DIR" -name "*.aab" -exec ls -lh {} \;
fi