A minimal template for building Android apps using Slint and Rust, with a modern component-based UI library.
- Android app project with Rust backend and Slint UI
- Modular UI components in
crates/slint-ui - Ready-to-use build scripts for Rust+Android
- Example integration with Gradle and JNI
- Rust (with
cargoandrustup) - cargo-generate (
cargo install cargo-generate) - Android SDK & NDK (set
ANDROID_HOMEandANDROID_NDK_HOME) - Java (JDK 11+, 17 recommended)
You can use cargo generate to create a new project from this template. Replace <branch> with main or any other branch you want to use.
cargo generate --git https://github.com/javiercont97/android_template_slint_rust.git --branch <branch> --name my_slint_appFor example, to use the main branch:
cargo generate --git https://github.com/javiercont97/android_template_slint_rust.git --branch main --name my_slint_app- Enter your new project directory:
cd my_slint_app - Build and install the APK on a connected device or emulator:
Or just build the APK:
./scripts/android.sh run
./scripts/android.sh build
- Edit UI components in
crates/slint-ui/ui/components/ - Add your Rust logic in
crates/slint-android/src/ - Update Gradle and AndroidManifest as needed in
android/
- Install Android Studio or the standalone command line tools.
- Install the following via the SDK Manager:
- Android SDK Platform (API 33 or newer recommended)
- Android SDK Build-Tools (e.g., 34.0.0 or newer)
- Android NDK (r25 or newer recommended)
- Set environment variables in your shell profile (e.g.,
~/.bashrcor~/.zshrc):export ANDROID_HOME="$HOME/Android/Sdk" export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/<ndk-version>" export PATH="$ANDROID_HOME/platform-tools:$PATH"
- You can find the NDK version folder under
$ANDROID_HOME/ndk/.
- minSdkVersion: 30 (Android 11)
- targetSdkVersion: 33 or newer (configurable in
android/app/build.gradle.kts)
- Java 17 is recommended for Android development (best compatibility with modern tools and Gradle).
- Java 11 is also supported if you need maximum compatibility, but Java 17+ is preferred for new projects.
- You can use a physical device (enable USB debugging) or an emulator (API 23+).
- For best results, use an emulator with an x86_64 or arm64 image matching your build target.
- If you encounter build errors, ensure your SDK/NDK paths and versions are correct.
- Use
sdkmanager --listto check installed components. - For more help, see the Android developer docs or the Slint Android book.
- You can use either a Linux-side Android SDK/NDK (recommended for builds) or point to your Windows SDK install for device/emulator management.
- Set both environment variables in your WSL shell profile:
export ANDROID_HOME="$HOME/Android/Sdk" # WSL/Linux SDK path export WIN_ANDROID_SDK="/mnt/c/Users/<User>/AppData/Local/Android/Sdk" # Windows SDK path
- The scripts will auto-detect and use the Windows
adb.exeandemulator.exeif available, which is much faster for running the Android emulator on Windows than inside WSL. - You can build in WSL and run/debug on a Windows emulator for best performance.
- Both setups are supported, but using the Windows-side emulator is strongly recommended for speed and compatibility.
MIT



