From 3574e60a8c3c58608db9f5d78ace9ea2622cac87 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Jul 2026 23:37:16 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E8=BF=87=20local.properties?= =?UTF-8?q?=20=E8=87=AA=E5=8A=A8=E8=A7=A3=E6=9E=90=20Flutter=20SDK=20?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_prod_apk.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/build_prod_apk.sh b/build_prod_apk.sh index a78c64f..709d3f2 100755 --- a/build_prod_apk.sh +++ b/build_prod_apk.sh @@ -6,12 +6,31 @@ ENV_FILE="env/prod.json" OUTPUT_DIR="build/outputs" APK_SRC="build/app/outputs/flutter-apk/app-release.apk" APK_DEST="$OUTPUT_DIR/rentaldrivego-release.apk" +LOCAL_PROPERTIES="android/local.properties" + +resolve_flutter() { + if command -v flutter &>/dev/null; then + command -v flutter + return 0 + fi + + if [[ -f "$LOCAL_PROPERTIES" ]]; then + local sdk_path + sdk_path="$(sed -n 's/^flutter\.sdk=//p' "$LOCAL_PROPERTIES" | head -n 1)" + if [[ -n "$sdk_path" && -x "$sdk_path/bin/flutter" ]]; then + echo "$sdk_path/bin/flutter" + return 0 + fi + fi + + return 1 +} # ── Checks ──────────────────────────────────────────────────────────────────── cd "$(dirname "$0")" -if ! command -v flutter &>/dev/null; then - echo "❌ flutter not found in PATH" +if ! FLUTTER_BIN="$(resolve_flutter)"; then + echo "❌ flutter not found in PATH or $LOCAL_PROPERTIES" exit 1 fi @@ -22,13 +41,13 @@ fi # ── Build ───────────────────────────────────────────────────────────────────── echo "▶ Cleaning previous build..." -flutter clean +"$FLUTTER_BIN" clean echo "▶ Fetching dependencies..." -flutter pub get +"$FLUTTER_BIN" pub get echo "▶ Building release APK (production)..." -flutter build apk --release --dart-define-from-file="$ENV_FILE" +"$FLUTTER_BIN" build apk --release --dart-define-from-file="$ENV_FILE" # ── Copy to output ──────────────────────────────────────────────────────────── mkdir -p "$OUTPUT_DIR"