Back to Ente

Ensu Android

mobile/native/android/apps/ensu/README.md

2.0.343.7 KB
Original Source

Ensu Android

Prerequisites

  • Android Studio or command-line tools
  • JDK 17
  • Android SDK with API level 35 (install in a default location or set ANDROID_HOME/ANDROID_SDK_ROOT)
  • Android NDK (install via sdkmanager "ndk;<version>"; optionally set NDK_VERSION to select a specific version)
  • Rust toolchain and cargo-ndk (cargo install cargo-ndk)
  • Python 3 (used to patch llama.cpp mtmd sources)

Quick scripts

From mobile/native/android/apps/ensu:

bash
./build.sh                 # builds Rust + debug APK
./build.sh apk             # builds Rust + release APK
./build.sh aab             # builds Rust + release AAB (app bundle)
./run.sh                   # builds + installs + launches on connected adb device

Helpful flags:

  • --skip-rust to skip Rust/jni rebuild
  • --endpoint <url> to set ENTE_API_ENDPOINT
  • --device <serial> for run.sh
  • legacy aliases still supported: release/release-apk and bundle/release-aab

Run ./build.sh --help or ./run.sh --help for full options.

Building

1. Build Rust Libraries

Before building the Android app, compile the Rust native libraries. Ensure the SDK is installed in a default location or set ANDROID_HOME/ANDROID_SDK_ROOT to the SDK containing an NDK. Optionally set NDK_VERSION to select a specific version. The build script applies the llama.cpp mtmd patch; set APPLY_LLAMA_MTMD_PATCH=0 to skip it.

bash
cd mobile/native/android/packages/rust/tool
./build_android.sh

This script produces the JNI .so artifacts in android/packages/rust/src/main/jniLibs/ (including libcore.so, libinference.so, libdb.so, and libsync.so). It also generates the UniFFI Kotlin bindings into:

  • android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/core.kt
  • android/packages/rust/src/main/kotlin/io/ente/labs/ensu_db/db.kt
  • android/packages/rust/src/main/kotlin/io/ente/labs/ensu_sync/sync.kt
  • android/packages/rust/src/main/kotlin/io/ente/labs/inference_rs/inference.kt

These generated files are gitignored and are refreshed each time build_android.sh runs.

2. Build Debug APK

bash
cd mobile/native/android/apps/ensu
./gradlew :app-ui:assembleDebug

Output: app-ui/build/outputs/apk/debug/app-ui-debug.apk

3. Build Release APK

bash
./gradlew :app-ui:assembleRelease

Output: app-ui/build/outputs/apk/release/app-ui-release.apk

Note: Release builds use a debug keystore located at debug.keystore. For production releases, configure your own signing keys in app-ui/build.gradle.kts.

Certificate Fingerprints

  • SHA1: 55:32:94:80:28:F7:C7:43:9F:41:07:58:4B:13:F1:56:38:00:75:0C
  • SHA256: 66:99:CF:8C:42:AF:42:7B:55:2C:96:20:54:E5:D6:95:89:FA:49:09:96:55:3A:53:04:5E:B3:9C:C3:4F:2E:66

To verify these fingerprints, use the following command:

bash
apksigner verify --print-certs <path_to_apk>

Installation

Install Debug Build

bash
./gradlew :app-ui:installDebug

Or via adb:

bash
adb install -r app-ui/build/outputs/apk/debug/app-ui-debug.apk

Install Release Build

bash
adb install -r app-ui/build/outputs/apk/release/app-ui-release.apk

Note: If upgrading from a differently signed build, uninstall first:

bash
adb uninstall io.ente.ensu

Custom API Endpoint

Set ENTE_API_ENDPOINT to override the default (https://api.ente.io).

bash
ENTE_API_ENDPOINT=https://your-endpoint ./gradlew :app-ui:installDebug

Or via Gradle property:

bash
./gradlew :app-ui:installDebug -PENTE_API_ENDPOINT=https://your-endpoint

Project Structure

  • app-ui/ - Main application module (Compose UI)
  • domain/ - Domain layer (business logic, state management)
  • data/ - Data layer (repositories, network, storage)
  • crypto-auth-core/ - Cryptographic authentication utilities