Skill v1.0.0
currentLLM-judged scan90/100name: expo-standalone-apk description: Use when building a standalone Expo Android APK. version: 1.0.0 author: Hermes Agent license: MIT metadata: hermes: tags: [expo, react-native, android, apk, gradle, nixos] related_skills: [expo-go-dev-loop]
Standalone Expo Android APK (this host)
Build, verify and hand over a sideloadable release APK for an Expo (SDK 57 era) project. Verified end-to-end on sops-pass-mobile (2026-09-28; Expo 57 / RN 0.86 / AGP 8.12 / Gradle wrapper 9.3.1, ~100 MB universal APK).
When to Use
- "Give me an APK I can install" for an Expo app on this machine.
- SDK-level bumps,
Failed to find target with hash string 'android-N'errors,
release-signing questions, assembleRelease failures.
Toolchain (pre-provisioned — install nothing globally)
- JDK 17 straight from the nix cache, e.g.:
nix shell nixpkgs#jdk17 -c bash -c 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(command -v javac)))); ... ./gradlew ...'
- Android SDK at
~/Android/Sdk(licenses accepted;cmdline-tools/latestpresent). android/local.propertiesmust containsdk.dir=/home/codebam/Android/Sdk—
expo prebuild does NOT write it (only expo run:android does); create it by hand.
- First gradle run downloads the distribution + deps: run it as a background
process with notify, 10–30 min. A --daemon (default) warms later builds a lot. Useful flags: -Pandroid.suppressUnsupportedCompileSdk=<N> and org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m in gradle.properties.
SDK levels: how "latest" actually resolves
- Pin levels in app.json via expo-build-properties so they survive
expo prebuild --clean: ["expo-build-properties", {"android": {"compileSdkVersion": 37, "targetSdkVersion": 37, "buildToolsVersion": "37.0.0"}}] → lands as android.compileSdkVersion=37 lines in android/gradle.properties.
- Platform-hash trap: AGP resolves integer
compileSdk = Nto a platform
directory literally named android-N, but versioned platforms install as android-37.0 / android-37.2. Install platforms;android-37.0 and add ln -s android-37.0 ~/Android/Sdk/platforms/android-37 — without it every subproject dies with Failed to find target with hash string 'android-37'.
- If compileSdk exceeds the AGP's tested max (8.12 → 36), put
android.suppressUnsupportedCompileSdk=37 in android/gradle.properties to silence the warning; the build works regardless.
- ANY
npx expo prebuildcan clear and regenerateandroid/— observed without
--clean too (prints "Clearing android") — it wipes hand-edits to gradle.properties (jvmargs, suppress flag) and deletes local.properties, so re-apply both after every prebuild run, not just clean ones.
Pipeline
npx expo prebuild --platform android --no-installonly when the native
project is missing or app.json plugin config changed; a committed android/ builds as-is.
cd android && ./gradlew --console=plain assembleRelease(background + notify)
→ android/app/build/outputs/apk/release/app-release.apk (universal, all ABIs).
- The release variant is signed with the RN template debug keystore
(android/app/debug.keystore) — fine for sideloading; say so in release notes and swap in a real keystore for anything beyond personal use.
- Verify before handing over — never trust a green build alone:
~/Android/Sdk/build-tools/37.0.0/aapt2 dump badging <apk> | head -5 (package, versionName/Code, sdkVersion, targetSdkVersion, native-code ABIs). Also confirm the effective compileSdkVersion there — it reflects what AGP REALLY used, not what you meant to set.
Delivery & gotchas
- Copy to a
dist/path (gitignored) and hand over withMEDIA:/abs/path/app.apk. - JS side is proven by
npm test+ the web smoke (expo-go-dev-loop skill); the APK
adds only the native shell + embedded Hermes bundle.
- A red screen on the PHONE's dev server ("Metro has encountered an error") means
the dev bundle is broken — usually app-code imports of @react-navigation/* (see expo-go-dev-loop) — it says nothing about the last built APK.
- Gradle logs: redirect to a file (
> /tmp/gradle-release.log 2>&1) — the tool
output buffer truncates otherwise; grep What went wrong for failures.