Build Android APK via Myket maven mirror (verified)

- Myket mirror serves maven2 layout at root https://maven.myket.ir (proxies
  Maven Central + Google/AGP); android/build.gradle uses it
- gradle-mirror.init.gradle template injects the mirror into all modules and
  pins build-tools 36 + Java 17 (this env lacks build-tools 35 / JDK 21)
- ANDROID.md updated with the exact working build command
- Produces app-debug.apk (~4.5 MB)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 15:22:34 +03:30
parent 38691154c8
commit 84ccbea56a
3 changed files with 52 additions and 39 deletions
+21 -8
View File
@@ -23,20 +23,33 @@ npm run android:open
> Point the app at the live server at build time: > Point the app at the live server at build time:
> `NEXT_PUBLIC_USE_SERVER=1 NEXT_PUBLIC_SERVER_URL=https://api.example.com npm run cap:sync` > `NEXT_PUBLIC_USE_SERVER=1 NEXT_PUBLIC_SERVER_URL=https://api.example.com npm run cap:sync`
## ⚠️ Maven mirror required (Iran) ## ⚠️ Maven mirror (Iran) — VERIFIED WORKING
Gradle pulls the Android Gradle Plugin from **dl.google.com** and **Maven Central**, Gradle pulls the Android Gradle Plugin from **dl.google.com** + **Maven Central**,
which are blocked in Iran — exactly like nuget.org. Provide a Maven/Gradle mirror blocked in Iran. The **Myket** mirror proxies both — at the **root** (no `/maven2`):
(your Nexus `maven-public` group that proxies Maven Central **and** Google's
android repo), then build with the init script: ```
https://maven.myket.ir
```
Copy `android/gradle-mirror.init.gradle.example``android/gradle-mirror.init.gradle`,
then build with the init script. (The `gradlew.bat` wrapper has a CLASSPATH quirk on
this setup, so invoke the wrapper jar with `java` directly):
```bash ```bash
cd android cd android
gradlew.bat assembleDebug --init-script gradle-mirror.init.gradle java -classpath gradle\wrapper\gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain \
assembleDebug --init-script gradle-mirror.init.gradle --no-daemon
# → app/build/outputs/apk/debug/app-debug.apk (≈4.5 MB)
``` ```
Copy `android/gradle-mirror.init.gradle.example``android/gradle-mirror.init.gradle` The init script also pins **build-tools 36.0.0** and **Java 17** compatibility,
and set your mirror URL(s). (Kept out of git; machine-specific.) which are the versions installed here (Capacitor 8 defaults to build-tools 35 / JDK 21).
On a CI box with JDK 21 + build-tools 35 you can drop those overrides.
> For Nexus instead of Myket directly: create a **maven2 (proxy)** repo with
> Remote storage URL `https://maven.myket.ir`, add it to a **maven2 (group)**,
> and point `MIRROR` at the group URL.
## Release (Cafe Bazaar / Myket) ## Release (Cafe Bazaar / Myket)
1. Generate a keystore: `keytool -genkey -v -keystore bargevasat.keystore -alias bargevasat -keyalg RSA -keysize 2048 -validity 10000` 1. Generate a keystore: `keytool -genkey -v -keystore bargevasat.keystore -alias bargevasat -keyalg RSA -keysize 2048 -validity 10000`
+2
View File
@@ -3,6 +3,7 @@
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.myket.ir' }
google() google()
mavenCentral() mavenCentral()
} }
@@ -19,6 +20,7 @@ apply from: "variables.gradle"
allprojects { allprojects {
repositories { repositories {
maven { url 'https://maven.myket.ir' }
google() google()
mavenCentral() mavenCentral()
} }
+29 -31
View File
@@ -1,42 +1,40 @@
// Route Gradle (Android Gradle Plugin + deps) through a Maven mirror — for // Build APK behind Iran's network using the Myket maven mirror.
// networks where dl.google.com / repo.maven.apache.org are blocked (Iran).
// //
// 1) copy this file to: android/gradle-mirror.init.gradle // copy to: android/gradle-mirror.init.gradle (git-ignored)
// 2) set MIRROR (and GOOGLE if your Nexus exposes Google's repo separately) // build: java -classpath gradle\wrapper\gradle-wrapper.jar \
// 3) build: gradlew.bat assembleDebug --init-script gradle-mirror.init.gradle // org.gradle.wrapper.GradleWrapperMain assembleDebug \
// --init-script gradle-mirror.init.gradle --no-daemon
// A Nexus "maven group" that proxies Maven Central AND Google's android repo: //
def MIRROR = "https://mirror.soroushasadi.com/repository/maven-public/" // NOTE: the mirror serves the maven2 layout at the ROOT (no /maven2 suffix).
// If Google's repo is a separate proxy, set it here (else leave = MIRROR): def MIRROR = "https://maven.myket.ir"
def GOOGLE = MIRROR
settingsEvaluated { settings -> settingsEvaluated { settings ->
settings.pluginManagement { settings.pluginManagement.repositories { maven { url MIRROR } }
repositories {
maven { url GOOGLE }
maven { url MIRROR }
}
}
try { try {
settings.dependencyResolutionManagement { settings.dependencyResolutionManagement.repositories { maven { url MIRROR } }
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
maven { url GOOGLE }
maven { url MIRROR }
}
}
} catch (ignored) { } } catch (ignored) { }
} }
allprojects { allprojects {
buildscript { buildscript { repositories { maven { url MIRROR } } }
repositories { repositories { maven { url MIRROR } }
maven { url GOOGLE }
maven { url MIRROR } // Environment workarounds (only needed when the exact SDK build-tools / JDK
// that Capacitor 8 expects aren't present — e.g. JDK 17 instead of 21, and
// build-tools 36 instead of 35). Remove on a CI with JDK 21 + build-tools 35.
afterEvaluate { p ->
if (p.plugins.hasPlugin('com.android.application') || p.plugins.hasPlugin('com.android.library')) {
p.android {
buildToolsVersion '36.0.0'
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}
}
p.tasks.withType(JavaCompile).configureEach {
sourceCompatibility = '17'
targetCompatibility = '17'
} }
} }
repositories {
maven { url GOOGLE }
maven { url MIRROR }
}
} }