This document explains how to build the Android APK from source. The Android app wraps the TypeScript proxy server (bundled as a Node.js CJS bundle) inside a Kotlin shell; OAuth login happens in the system browser via Custom Tabs.
- Bun 1.4.0 (pinned — CI and release builds use exactly this version) — for building the TS bundle
- JDK 17 (Temurin recommended)
- Android SDK with platform
android-35and build-tools35.0.0 - GNU binutils (
ar,tar,xz) on PATH — only needed if you re-extract the Termux Node.js.debpackages viascripts/extract-termux-deps.sh(the extracted.sofiles are committed inapp/src/main/jniLibs/arm64-v8a/)
# 1. Install JS deps
bun install
# 2. Build the esbuild CJS bundles (outputs dist/android/server.cjs and
# dist/android/captcha-worker-entry.cjs)
bun run build:android-bundle
cp dist/android/server.cjs Android-APP/app/src/main/assets/server_bundle/server.cjs
cp dist/android/captcha-worker-entry.cjs Android-APP/app/src/main/assets/server_bundle/captcha-worker-entry.cjs
# 3. Build the debug APK (Node binary + dependency .so files are committed
# in jniLibs — nothing is downloaded at build time)
cd Android-APP
./gradlew assembleDebug
# 4. Sideload onto a device (USB debugging enabled)
adb install -r app/build/outputs/apk/debug/app-debug.apkRequires GitHub Actions secrets ANDROID_KEYSTORE_BASE64,
ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD. The
release CI workflow (.github/workflows/release.yml, manual dispatch with a
vX.Y.Z tag input) builds a signed APK. For local signed builds:
cd Android-APP
./gradlew assembleRelease \
-PandroidSigning.keystoreFile=/path/to/release.keystore \
-PandroidSigning.storePassword=... \
-PandroidSigning.keyAlias=... \
-PandroidSigning.keyPassword=...Android-APP/— Gradle project; everything Android-specific lives here.Android-APP/app/src/main/java/com/zcode/proxy/— Kotlin shell.Android-APP/app/src/main/assets/server_bundle/— generatedserver.cjspluscaptcha-worker-entry.cjs(start-plan captchas are solved strictly in worker processes on Android); the web UI, system prompt and config template are inlined into the bundle.server.cjsis gitignored build output;captcha-worker-entry.cjsis committed to the repo (a regenerated copy must be re-committed) — regenerate viabun run build:android-bundle+ copy both files fromdist/android/into it before building (Gradle'scheckServerBundlepreBuild task fails with a hint if either is missing).Android-APP/app/src/main/jniLibs/arm64-v8a/— committed Node.js binary (libnode.so) + Termux dependency.sofiles, extracted once viascripts/extract-termux-deps.sh.Android-APP/gradle/node-binary.lock.json— pinned URLs and SHA256s.
- App taps "Login with {provider}" →
ControlClient.startOAuth(provider). - Node starts the OAuth flow and returns the authorize URL. Both
providers use the server-mediated CLI poll flow (ZCode 3.12.3 parity):
/oauth/cli/init+/oauth/cli/poll/{flow_id}at zcode.z.ai; the authorize URL carries the/app/oauth/logininterstitial param. No localhost callback is involved. - App opens the URL with
CustomTabsIntent.launchUrl()— the system browser handles login (OAuth providers block embedded WebViews). - User authenticates in the browser; after authorization the browser lands
on the interstitial (which records the code server-side) and then tries to
bounce to
zcode://. That deep link only matters to the official desktop app — the browser's "cannot open link" notice is expected and can be ignored; the login has already completed server-side. - Node's background poll flips to
ready, resolves the coding-plan API key and persists the encrypted credential; the app's 1.5s status polling reflects the logged-in state automatically.
- Start-plan tier untested on Android — captchas are solved in dedicated
worker processes (
captcha-worker-entry.cjs; strict mode — a missing or failing worker is a hard solve failure, never a main-thread fallback), but the tier has not been validated on-device. Coding-plan (direct upstream) is the supported tier on Android v1. - Not Play Store-distributed — APK is sideload-only. Play Store rejects apps
that launch external binaries from
jniLibs/. - arm64-v8a only — no x86 / armeabi-v7a support. Covers 99%+ of modern Android devices.
- No iOS build — Android only for v1.
INTERNET— proxy server + upstream HTTPSACCESS_NETWORK_STATE— detect connectivity changesFOREGROUND_SERVICE+FOREGROUND_SERVICE_DATA_SYNC— keep Node.js alive when the app is backgroundedPOST_NOTIFICATIONS— required on Android 13+ for the foreground service notificationWAKE_LOCK— prevent CPU sleep during long LLM calls