#!/usr/bin/env bash # Builds a Play-ready App Bundle plus the native debug symbols. set -euo pipefail cd "$(dirname "$0")/.." export ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$HOME/Android/Sdk/ndk/28.2.13676358}" echo '==> Rust release libraries' cargo ndk --platform 24 -t arm64-v8a -t armeabi-v7a -o app/android/app/src/main/jniLibs build --release -p ffi for abi in arm64-v8a armeabi-v7a; do so="app/android/app/src/main/jniLibs/$abi/libffi.so" # 16 KB pages are mandatory for 64-bit ABIs; 32-bit ARM still uses 4 KB. case "$abi" in arm64-v8a|x86_64) expect=0x4000 ;; *) expect=0x1000 ;; esac if readelf -lW "$so" | awk -v e="$expect" '$1=="LOAD" && $NF!=e {found=1} END{exit !found}'; then echo "ERROR: $abi is not aligned to $expect" >&2 exit 1 fi echo "OK: $abi aligned to $expect ($(stat -c%s "$so") bytes)" done echo '==> Native debug symbols (unstripped)' rm -rf build/native-symbols mkdir -p build/native-symbols for abi in arm64-v8a armeabi-v7a; do mkdir -p "build/native-symbols/$abi" cp "app/android/app/src/main/jniLibs/$abi/libffi.so" "build/native-symbols/$abi/" done (cd build/native-symbols && zip -qr ../native-debug-symbols.zip .) echo "symbols: $(stat -c%s build/native-debug-symbols.zip) bytes" echo '==> Flutter bundle (AAB)' (cd app && flutter build appbundle --release) AAB=app/build/app/outputs/bundle/release/app-release.aab echo "aab: $(stat -c%s "$AAB") bytes" unzip -l "$AAB" | grep -E 'lib/|AndroidManifest' | head -8 echo '==> Release APK for device smoke test' (cd app && flutter build apk --release --target-platform android-arm64) echo "apk: $(stat -c%s app/build/app/outputs/flutter-apk/app-release.apk) bytes"