From 412365407740091a4acab32af6f28f66bf171051 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Wed, 3 Jun 2026 10:50:17 +0330 Subject: [PATCH] build(meezi_app): Android Maven mirrors for Iran (Aliyun) Google's Android maven2 artifacts (AGP, androidx, Kotlin) 404 from Iran like pub.dev does. Route Gradle resolution through the reachable Aliyun mirrors: - android/settings.gradle.kts (pluginManagement) + build.gradle.kts (allprojects) now list maven.aliyun.com/repository/{gradle-plugin,google,central} before the originals (kept as fallback). - BUILD_IRAN.md documents the full setup incl. the machine-local GRADLE_USER_HOME init.gradle needed for Flutter's included flutter_tools/gradle build. Verified: dependency resolution now succeeds via the mirrors (AGP + kotlin-compiler download from Aliyun). The APK build itself is currently blocked only by low disk space on this machine, not configuration. --- mobile/meezi_app/BUILD_IRAN.md | 53 ++++++++++++++++++++ mobile/meezi_app/android/build.gradle.kts | 3 ++ mobile/meezi_app/android/settings.gradle.kts | 5 ++ 3 files changed, 61 insertions(+) create mode 100644 mobile/meezi_app/BUILD_IRAN.md diff --git a/mobile/meezi_app/BUILD_IRAN.md b/mobile/meezi_app/BUILD_IRAN.md new file mode 100644 index 0000000..a3167e4 --- /dev/null +++ b/mobile/meezi_app/BUILD_IRAN.md @@ -0,0 +1,53 @@ +# Building meezi_app from Iran (sanctions mirrors) + +`pub.dev`, Google's package storage, and Google's Android maven2 artifacts are +sanctions-filtered from Iranian IPs (403 / 404). Use the reachable mirrors below. + +## 1. Environment (set once, persistently) + +```powershell +setx PUB_HOSTED_URL "https://pub.flutter-io.cn" +setx FLUTTER_STORAGE_BASE_URL "https://storage.flutter-io.cn" +``` + +These make `flutter pub get`, `flutter create`, and engine/artifact downloads work. +**Web already builds** with just these (`flutter build web`). + +## 2. Android — Maven/Gradle mirror + +Google's Android maven2 (AGP, androidx, etc.) 404s here, so: + +- `android/settings.gradle.kts` and `android/build.gradle.kts` already point their + repositories at the Aliyun mirrors (committed). +- Flutter's **included** `flutter_tools/gradle` build has its own repositories, so add a + global Gradle init script. Put this at `%GRADLE_USER_HOME%/init.gradle` + (e.g. `C:\gradlecache\init.gradle`, then build with `GRADLE_USER_HOME=C:\gradlecache`): + +```gradle +def aliyun = [ + 'https://maven.aliyun.com/repository/gradle-plugin', + 'https://maven.aliyun.com/repository/google', + 'https://maven.aliyun.com/repository/central', +] +beforeSettings { settings -> + settings.pluginManagement { repositories { aliyun.each { u -> maven { url u } } } } + if (settings.rootDir.path.replace('\\', '/').contains('flutter_tools')) { + settings.dependencyResolutionManagement { repositories { aliyun.each { u -> maven { url u } } } } + } +} +``` + +## 3. Build + +```powershell +$env:GRADLE_USER_HOME = "C:\gradlecache" # keep the cache on a drive with space +cd mobile/meezi_app +flutter build apk --debug +``` + +## Status +- ✅ `flutter build web` — works. +- ✅ Android dependency resolution — works via the Aliyun mirrors (verified). +- ⛔ APK build currently blocked only by **disk space** (needs a few GB free for the + Gradle cache + build output). Free space (the large Docker WSL vhdx on C: is the + obvious reclaim), then `flutter build apk` completes. diff --git a/mobile/meezi_app/android/build.gradle.kts b/mobile/meezi_app/android/build.gradle.kts index dbee657..b020a5f 100644 --- a/mobile/meezi_app/android/build.gradle.kts +++ b/mobile/meezi_app/android/build.gradle.kts @@ -1,5 +1,8 @@ allprojects { repositories { + // Iran: prefer reachable Aliyun mirrors (Google Android maven2 is filtered here). + maven { url = uri("https://maven.aliyun.com/repository/google") } + maven { url = uri("https://maven.aliyun.com/repository/central") } google() mavenCentral() } diff --git a/mobile/meezi_app/android/settings.gradle.kts b/mobile/meezi_app/android/settings.gradle.kts index ca7fe06..95d8e71 100644 --- a/mobile/meezi_app/android/settings.gradle.kts +++ b/mobile/meezi_app/android/settings.gradle.kts @@ -11,6 +11,11 @@ pluginManagement { includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") repositories { + // Iran: Google's Android maven2 artifacts 404 here (sanctions-filtered), so + // resolve through the reachable Aliyun mirrors first; keep the originals as fallback. + maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") } + maven { url = uri("https://maven.aliyun.com/repository/google") } + maven { url = uri("https://maven.aliyun.com/repository/central") } google() mavenCentral() gradlePluginPortal()