Skip to content

Build for Android

Checked against 0015716 on 2026-11-10. The files it covers are unchanged since.

The Android host is a Compose app in hosts/android. One script, hosts/android/build.sh, builds niso for arm64 Android (libniso_android.so), the example pages and the app with Gradle, then installs the app on an emulator or a connected phone and launches the page.

  • The Android SDK, with the NDK, the platform tools and the emulator. The scripts look for it in ANDROID_HOME, or else in Android Studio’s default place: ~/Library/Android/sdk on macOS, ~/Android/Sdk on Linux. They take the newest NDK under ndk/.
  • A JDK 17. On macOS the script asks /usr/libexec/java_home -v 17; on Linux it takes the javac on the PATH unless JAVA_HOME is set. It stops if the JDK isn’t 17.
  • Rust’s aarch64-linux-android target: rustup target add aarch64-linux-android.
  • Node and pnpm, for the example pages, and the QuickJS-ng submodule (git submodule update --init).
  • On Linux, an x86_64 machine: the NDK ships its prebuilt toolchain for x86_64 hosts only, so arm64 Linux can’t build the host (Linux notes).

--no-launch only builds; it has to come after the example name:

Terminal window
hosts/android/build.sh counter --no-launch

The debug APK is hosts/android/app/build/outputs/apk/debug/app-debug.apk.

Without --no-launch the script installs the APK with adb and starts the page. If no device or emulator is attached, it starts the emulator AVD named by NISO_AVD (default quilt) and waits for it to boot:

Terminal window
hosts/android/build.sh counter

Anything after the example name goes to the app as am start extras: --es niso.taps "X,Y;X,Y" taps after launch, --ez niso.probe true writes the page’s element boxes to the app’s files/probe.json, and --ez niso.notext true draws boxes without text.

Command What the app runs
hosts/android/build.sh EXAMPLE examples/dist/EXAMPLE.js
hosts/android/build.sh --app LIB an arm64 shared library that exports niso_app_main, linked against libniso_android.so (Native apps)
hosts/android/build.sh --jvm DIR CLASS the Java sources in DIR built into the app, running CLASS, a Consumer<dev.niso.dom.Dom> (Java and Kotlin)

NISO_ENGINE=porffor compiles the example into the native library ahead of time with Porffor instead of running it on QuickJS (see JavaScript).

To build an APK you can hand out, hosts/android/apk.sh makes a release APK per example, each with its own package (dev.niso.host.EXAMPLE) and launcher label so several install side by side, signed with the debug key, in target/apk/niso-EXAMPLE.apk:

Terminal window
hosts/android/apk.sh timer:Stopwatch radio

hosts/android/niso is the page host as an Android library, which the host app (hosts/android/app) and other apps build on; examples/ihatemyphone is one such app. Apps built on it source hosts/android/native.sh to build libniso_android.so into the library. See Android for what the host draws natively, its widget and its ongoing notification.