Skip to content

Commit 6287f60

Browse files
therealalephclaude
andauthored
v1.0.0: multi-arch Android APK + GitHub Actions release job + install docs (#30)
Version bump reflects the scope — a unified Rust core that now ships for desktop (Linux/macOS/Windows) AND Android from the same crate. Android changes: - build.gradle.kts: ABI filters expanded to arm64-v8a + armeabi-v7a + x86_64 + x86. cargoBuild{Debug,Release} pass all four ABIs to cargo-ndk in a single invocation. normalizeTun2proxySo() walks every ABI dir now (was arm64-only). - Release buildType signs with the debug keystore — no Play Store target, so signature identity doesn't matter, installability does. Gradle auto-provisions ~/.android/debug.keystore if absent, so CI runners inherit this without extra setup. - versionName 1.0.0, versionCode 100 (room to bump monotonically). CI: - release.yml gets a dedicated `android:` job that sets up JDK 17, Android SDK/NDK 26, all four rust-android targets, installs cargo-ndk, runs assembleRelease, and uploads a single universal APK named `mhrv-rs-android-universal-v<version>.apk` into the same `dist/` collected by the release job downstream. - `release:` job now gates on `needs: [build, android]` so tagging v1.0.0 triggers both build matrices before cutting the GitHub release. Docs: - docs/android.md — full 10-step install walk-through: APK sideload, Apps Script deployment (with "Advanced → Go to (unsafe) → Allow" reality check), config paste, SNI reachability test, MITM CA install with OEM-specific nav paths (Pixel / Samsung / Xiaomi), Start, troubleshooting common failure modes. Also documents the known limitations — Cloudflare Turnstile loops (inherent to the Apps Script egress IP pool), UDP/QUIC not tunnelled, IPv6 leaks, Apps Script daily quota — so users know what to expect before trying it on a site that won't work. - releases/README.md — APK row added to the English and Persian tables, version bumped everywhere to v1.0.0. - Top-level README — Android listed under Platforms with a link to docs/android.md. Release artifact: - releases/mhrv-rs-android-universal-v1.0.0.apk — 38 MB universal APK built locally from this tree. Installs + launches on API 24+. The CI job will regenerate it on tag push; this is the copy committed for users who can't reach GitHub Releases. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8c607a5 commit 6287f60

8 files changed

Lines changed: 341 additions & 47 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,73 @@ jobs:
208208
dist/${{ matrix.name }}-app.zip
209209
if-no-files-found: ignore
210210

211+
# Android build — separate job so it doesn't inflate the matrix. The
212+
# Rust side here cross-compiles to FOUR ABIs (arm64-v8a, armeabi-v7a,
213+
# x86_64, x86) via cargo-ndk and drops the .so files into the Gradle
214+
# project's jniLibs/ tree, which then packages them into a single
215+
# universal APK. Users pick it once, no per-ABI split.
216+
android:
217+
runs-on: ubuntu-22.04
218+
steps:
219+
- uses: actions/checkout@v4
220+
221+
- name: Set up JDK 17
222+
uses: actions/setup-java@v4
223+
with:
224+
distribution: temurin
225+
java-version: 17
226+
227+
- name: Set up Android SDK
228+
uses: android-actions/setup-android@v3
229+
with:
230+
cmdline-tools-version: 11076708
231+
232+
- name: Install NDK
233+
run: |
234+
yes | sdkmanager --install "ndk;26.1.10909125" >/dev/null
235+
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> "$GITHUB_ENV"
236+
237+
- uses: dtolnay/rust-toolchain@stable
238+
with:
239+
targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android
240+
241+
- name: Install cargo-ndk
242+
run: cargo install cargo-ndk --locked
243+
244+
# `./gradlew :app:assembleRelease` triggers cargoBuildRelease first
245+
# which invokes cargo-ndk with all four targets, then Gradle packages
246+
# the APK (release buildType signed with the debug keystore — see
247+
# android/app/build.gradle.kts comment explaining why).
248+
- name: Build release APK
249+
working-directory: android
250+
run: |
251+
chmod +x ./gradlew
252+
./gradlew :app:assembleRelease --no-daemon --stacktrace
253+
254+
- name: Rename APK with version
255+
working-directory: android
256+
run: |
257+
VER="${GITHUB_REF#refs/tags/v}"
258+
SRC="app/build/outputs/apk/release/app-release.apk"
259+
if [ ! -f "$SRC" ]; then
260+
# Some AGP versions name it differently when the release config
261+
# can't be auto-signed. Catch that up front with a clear error
262+
# instead of a silent missing-artifact later.
263+
echo "::error::expected $SRC to exist; actual outputs:"
264+
find app/build/outputs/apk -type f -name '*.apk' -print
265+
exit 1
266+
fi
267+
mkdir -p ../dist
268+
cp "$SRC" "../dist/mhrv-rs-android-universal-v${VER}.apk"
269+
270+
- uses: actions/upload-artifact@v4
271+
with:
272+
name: mhrv-rs-android-universal
273+
path: dist/*.apk
274+
if-no-files-found: error
275+
211276
release:
212-
needs: build
277+
needs: [build, android]
213278
runs-on: ubuntu-latest
214279
permissions:
215280
contents: write

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mhrv-rs"
3-
version = "0.9.4"
3+
version = "1.0.0"
44
edition = "2021"
55
description = "Rust port of MasterHttpRelayVPN -- DPI bypass via Google Apps Script relay with domain fronting"
66
license = "MIT"

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ For a handful of Google-owned domains (`google.com`, `youtube.com`, `fonts.googl
4747

4848
## Platforms
4949

50-
Linux (x86_64, aarch64), macOS (x86_64, aarch64), Windows (x86_64). Prebuilt binaries on the [releases page](https://github.com/therealaleph/MasterHttpRelayVPN-RUST/releases).
50+
Linux (x86_64, aarch64), macOS (x86_64, aarch64), Windows (x86_64), **Android 7.0+** (universal APK covering arm64, armv7, x86_64, x86). Prebuilt binaries on the [releases page](https://github.com/therealaleph/MasterHttpRelayVPN-RUST/releases).
51+
52+
**Android users** — grab `mhrv-rs-android-universal-v*.apk` and follow the full walk-through in [docs/android.md](docs/android.md). The Android build runs the exact same `mhrv-rs` crate as the desktop (via JNI) and adds a TUN bridge via `tun2proxy`, so every app on the device routes through the proxy without per-app configuration.
5153

5254
## What's in a release
5355

‎android/app/build.gradle.kts‎

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ android {
1414
applicationId = "com.therealaleph.mhrv"
1515
minSdk = 24 // Android 7.0 — covers 99%+ of live devices.
1616
targetSdk = 34
17-
versionCode = 1
18-
versionName = "0.1.0"
19-
20-
// Only arm64 for now — we can add armeabi-v7a in a second pass
21-
// if field reports need it. Android emulators on Apple Silicon
22-
// only run arm64 natively, so keeping things aarch64-only makes
23-
// the dev loop fast.
17+
versionCode = 100
18+
versionName = "1.0.0"
19+
20+
// Ship all four mainstream Android ABIs:
21+
// - arm64-v8a — 95%+ of real-world Android phones since 2019
22+
// - armeabi-v7a — older/cheaper devices still on 32-bit ARM
23+
// - x86_64 — Android emulator on Intel Macs + Chromebooks
24+
// - x86 — legacy 32-bit Intel emulator; cheap to include
25+
// Per-ABI .so files push the APK up to ~50 MB, but users expect one
26+
// APK that Just Works rather than "pick the right ABI" which nobody
27+
// does correctly. Google Play would auto-split; we ship universal.
2428
ndk {
25-
abiFilters += listOf("arm64-v8a")
29+
abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86_64", "x86")
2630
}
2731
}
2832

@@ -33,6 +37,15 @@ android {
3337
getDefaultProguardFile("proguard-android-optimize.txt"),
3438
"proguard-rules.pro",
3539
)
40+
// Sign release builds with the debug keystore so users can
41+
// sideload the APK without us shipping a proper release key.
42+
// The project has no Play Store presence, so signature
43+
// identity per-build doesn't matter — installability does.
44+
// Gradle auto-creates `~/.android/debug.keystore` on first use;
45+
// CI runners inherit that behaviour. Anyone rebuilding from
46+
// source gets their own signature, which is what we want for
47+
// an open-source project: trust the source, not a key we hold.
48+
signingConfig = signingConfigs.getByName("debug")
3649
}
3750
}
3851

@@ -96,55 +109,62 @@ dependencies {
96109
val rustCrateDir = rootProject.projectDir.parentFile
97110
val jniLibsDir = file("src/main/jniLibs")
98111

99-
// After cargo-ndk dumps artifacts into jniLibs/arm64-v8a/, the tun2proxy
100-
// cdylib lands as `libtun2proxy-<hash>.so` (rustc's deps/ naming convention,
101-
// because tun2proxy is a transitive dep not a root crate). Android's
102-
// System.loadLibrary expects a stable name, and the hash changes between
103-
// builds, so we normalize it to `libtun2proxy.so` here. Also deletes any
104-
// stale hash-suffixed copies from previous builds.
112+
// After cargo-ndk dumps artifacts into each jniLibs/<abi>/ dir, the
113+
// tun2proxy cdylib lands as `libtun2proxy-<hash>.so` (rustc's deps/ naming
114+
// convention, because tun2proxy is a transitive dep not a root crate).
115+
// Android's System.loadLibrary expects a stable name, and the hash changes
116+
// between builds, so we normalize it to `libtun2proxy.so` in every ABI dir.
117+
// Also deletes any stale hash-suffixed copies from previous builds.
105118
fun normalizeTun2proxySo() {
106-
val abiDir = file("src/main/jniLibs/arm64-v8a")
107-
if (!abiDir.isDirectory) return
108-
val hashed = abiDir.listFiles { f -> f.name.matches(Regex("libtun2proxy-[0-9a-f]+\\.so")) }
109-
?: emptyArray()
110-
// Keep only the newest (release build) and rename it.
111-
val newest = hashed.maxByOrNull { it.lastModified() }
112-
if (newest != null) {
113-
val target = abiDir.resolve("libtun2proxy.so")
114-
if (target.exists()) target.delete()
115-
newest.copyTo(target, overwrite = true)
119+
val jniLibsRoot = file("src/main/jniLibs")
120+
if (!jniLibsRoot.isDirectory) return
121+
jniLibsRoot.listFiles()?.filter { it.isDirectory }?.forEach { abiDir ->
122+
val hashed = abiDir.listFiles { f -> f.name.matches(Regex("libtun2proxy-[0-9a-f]+\\.so")) }
123+
?: emptyArray()
124+
val newest = hashed.maxByOrNull { it.lastModified() }
125+
if (newest != null) {
126+
val target = abiDir.resolve("libtun2proxy.so")
127+
if (target.exists()) target.delete()
128+
newest.copyTo(target, overwrite = true)
129+
}
130+
hashed.forEach { it.delete() }
116131
}
117-
hashed.forEach { it.delete() }
118132
}
119133

134+
// All ABIs we ship. Keep in sync with `android.defaultConfig.ndk.abiFilters`
135+
// above; if these drift, the APK either includes .so files with no matching
136+
// ABI entry (dead weight) or advertises ABIs with no .so (runtime
137+
// UnsatisfiedLinkError on devices that pick that split).
138+
val androidAbis = listOf("arm64-v8a", "armeabi-v7a", "x86_64", "x86")
139+
120140
tasks.register<Exec>("cargoBuildDebug") {
121141
group = "build"
122142
// Intentionally ALWAYS uses --release. The Rust debug build is 80+MB
123143
// of unoptimized object code vs 3MB with release; the 20x APK bloat is
124144
// never worth it just for a Rust stack trace you wouldn't see in
125145
// logcat anyway. If you need Rust debug symbols, temporarily drop
126146
// `--release` below and accept the APK size.
127-
description = "Cross-compile mhrv_rs for arm64-v8a (release — same as cargoBuildRelease)"
147+
description = "Cross-compile mhrv_rs for all ABIs (release — same as cargoBuildRelease)"
128148
workingDir = rustCrateDir
129-
commandLine(
130-
"cargo", "ndk",
131-
"-t", "arm64-v8a",
132-
"-o", jniLibsDir.absolutePath,
133-
"build", "--release",
134-
)
149+
commandLine(buildList<String> {
150+
add("cargo"); add("ndk")
151+
androidAbis.forEach { add("-t"); add(it) }
152+
add("-o"); add(jniLibsDir.absolutePath)
153+
add("build"); add("--release")
154+
})
135155
doLast { normalizeTun2proxySo() }
136156
}
137157

138158
tasks.register<Exec>("cargoBuildRelease") {
139159
group = "build"
140-
description = "Cross-compile mhrv_rs for arm64-v8a (release)"
160+
description = "Cross-compile mhrv_rs for all ABIs (release)"
141161
workingDir = rustCrateDir
142-
commandLine(
143-
"cargo", "ndk",
144-
"-t", "arm64-v8a",
145-
"-o", jniLibsDir.absolutePath,
146-
"build", "--release",
147-
)
162+
commandLine(buildList<String> {
163+
add("cargo"); add("ndk")
164+
androidAbis.forEach { add("-t"); add(it) }
165+
add("-o"); add(jniLibsDir.absolutePath)
166+
add("build"); add("--release")
167+
})
148168
doLast { normalizeTun2proxySo() }
149169
}
150170

0 commit comments

Comments
 (0)