#!/bin/bash
# ShowenV2 Flutter APK 编译脚本
# 环境: Debian 11 ARM64

export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64
export ANDROID_HOME=/home/showen/Android
export PATH="/home/showen/flutter-sdk/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$JAVA_HOME/bin:$PATH"

cd /home/showen/Showen/ShowenV2/clients/flutter

echo "=== 环境检查 ==="
flutter --version
java -version
echo "ANDROID_HOME=$ANDROID_HOME"

echo "=== flutter pub get ==="
flutter pub get

echo "=== dart analyze ==="
dart analyze

echo "=== 编译 Release APK ==="
flutter build apk --release

echo "=== 编译结果 ==="
ls -lh build/app/outputs/flutter-apk/*.apk 2>/dev/null || echo "APK 未生成"
