ci(android): Containerized build script for reproducible APK compilation #45

Open
opened 2026-10-25 13:49:40 +01:00 by harald · 2 comments
Owner

Description

Create a reproducible build script or container configuration (Containerfile / Dockerfile) containing the required Android SDK, NDK, and Rust toolchain targets to build debug and release APKs without host pollution.

Scope of Work

  1. Provide a Containerfile / Dockerfile:
    • Base image: almalinux:9 or debian:bookworm-slim.
    • Install Android Command Line Tools, SDK Platform 34, and NDK (r25c+ or r26+).
    • Install Rust via rustup with targets aarch64-linux-android and x86_64-linux-android.
    • Install cargo-apk.
  2. Provide a helper build script (scripts/build-android-apk.sh):
    • Sets ANDROID_HOME and ANDROID_NDK_HOME.
    • Runs cargo apk build --target aarch64-linux-android --release.
    • Outputs the generated .apk into target/android-artifacts/.

Acceptance Criteria

  • Running the build script inside the container produces a signed debug APK that can be deployed via adb install.
  • No dependencies beyond Podman/Docker required on the host system.
### Description Create a reproducible build script or container configuration (Containerfile / Dockerfile) containing the required Android SDK, NDK, and Rust toolchain targets to build debug and release APKs without host pollution. ### Scope of Work 1. Provide a `Containerfile` / `Dockerfile`: - Base image: `almalinux:9` or `debian:bookworm-slim`. - Install Android Command Line Tools, SDK Platform 34, and NDK (r25c+ or r26+). - Install Rust via `rustup` with targets `aarch64-linux-android` and `x86_64-linux-android`. - Install `cargo-apk`. 2. Provide a helper build script (`scripts/build-android-apk.sh`): - Sets `ANDROID_HOME` and `ANDROID_NDK_HOME`. - Runs `cargo apk build --target aarch64-linux-android --release`. - Outputs the generated `.apk` into `target/android-artifacts/`. ### Acceptance Criteria - Running the build script inside the container produces a signed debug APK that can be deployed via `adb install`. - No dependencies beyond Podman/Docker required on the host system.
Author
Owner

Corrections after checking the code (planned for the future, not started)

  • cargo-apk is deprecated and unmaintained. Better options:
    • xbuild (x build --platform android)
    • cargo-ndk, which builds the .so, plus a minimal Gradle wrapper project that packages and signs it. This is the most future-proof option and also gives a proper AndroidManifest.xml for intents and file access (see #43).
  • AlmaLinux 9 matches the current CI and build host, so it is a reasonable base image. The NDK also needs unzip, java (JDK 17) for Gradle or sdkmanager, and clang from the NDK as the linker (CC_aarch64_linux_android, CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER).
  • The Gitea CI already builds .deb and .AppImage for each tag. A later step could build the APK there too, signed with a release key kept as a CI secret, and add it to the release assets with SHA256SUMS and minisign like the others.
  • Updates: the built-in updater (src/updater.rs) is Linux only. On Android, updates would come from a store or F-Droid repo, or be installed by hand from the APK.
**Corrections after checking the code** (planned for the future, not started) - `cargo-apk` is deprecated and unmaintained. Better options: - `xbuild` (`x build --platform android`) - `cargo-ndk`, which builds the `.so`, plus a minimal Gradle wrapper project that packages and signs it. This is the most future-proof option and also gives a proper `AndroidManifest.xml` for intents and file access (see #43). - AlmaLinux 9 matches the current CI and build host, so it is a reasonable base image. The NDK also needs `unzip`, `java` (JDK 17) for Gradle or sdkmanager, and `clang` from the NDK as the linker (`CC_aarch64_linux_android`, `CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER`). - The Gitea CI already builds `.deb` and `.AppImage` for each tag. A later step could build the APK there too, signed with a release key kept as a CI secret, and add it to the release assets with SHA256SUMS and minisign like the others. - Updates: the built-in updater (`src/updater.rs`) is Linux only. On Android, updates would come from a store or F-Droid repo, or be installed by hand from the APK.
Author
Owner

Erster Schritt in v0.39.3: scripts/package-android.sh baut target/ink-notes_<version>_arm64.apk ohne Gradle.

  • Ablauf: NDK-Build der cdylib, dann aapt2, zipalign und apksigner.
  • Das Manifest liegt in packaging/android/AndroidManifest.xml.
  • Signiert wird mit ANDROID_KEYSTORE, ANDROID_KEYSTORE_PASS und ANDROID_KEY_ALIAS; fehlen sie, mit dem Debug-Schlüssel.

Noch offen: Container-Image für den Build, Einbindung in die CI, eigener Release-Schlüssel. Die APK kommt erst ins Release, wenn sie auf einem Gerät getestet ist.

Erster Schritt in **v0.39.3**: `scripts/package-android.sh` baut `target/ink-notes_<version>_arm64.apk` ohne Gradle. - Ablauf: NDK-Build der `cdylib`, dann `aapt2`, `zipalign` und `apksigner`. - Das Manifest liegt in `packaging/android/AndroidManifest.xml`. - Signiert wird mit `ANDROID_KEYSTORE`, `ANDROID_KEYSTORE_PASS` und `ANDROID_KEY_ALIAS`; fehlen sie, mit dem Debug-Schlüssel. Noch offen: Container-Image für den Build, Einbindung in die CI, eigener Release-Schlüssel. Die APK kommt erst ins Release, wenn sie auf einem Gerät getestet ist.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: harald/ink-notes#45