ratadroid is a command-line tool for building Ratatui (TUI) applications that run natively on Android. It scaffolds Android NativeActivity projects with Rust integration, manages Gradle-based builds, and provides development workflow automation.
Note: This is an experimental tool. The Ratatui Android Runtime is functional but may have limitations. Expect some rough edges.
- Project scaffolding: Creates complete Android NativeActivity projects with Gradle and Rust integration
- Bundled template: The template is embedded in the CLI binary - no external files needed
- Gradle builds: Uses Gradle for Android APKs with automatic Rust library compilation via
cargo-ndk - Device management: Detects connected devices, prefers physical devices, and can start emulators automatically
- Logcat streaming: The
run --logoption streams colorized logcat output after launching - Ratatui Android Runtime: Custom terminal emulator that renders Ratatui applications directly to Android surfaces
- Touch and keyboard input: Touch events mapped to Ratatui mouse events, keyboard support with international handling
- Environment diagnostics: The
doctorcommand checks your development environment
Build from source:
cd ratadroid_cli
cargo install --path .Or run directly:
cargo run -- <command>- Android SDK - Install via Android Studio
- Android NDK - Install via Android Studio SDK Manager
- Rust toolchain - Install via rustup
- cargo-ndk - Install with
cargo install cargo-ndk
Gradle will be downloaded automatically via Gradle Wrapper.
Run ratadroid doctor --fix to check your environment.
ratadroid new my-app
cd my-appThis creates a complete Android project with:
- Gradle build files
- Rust library with Ratatui Android Runtime
- Demo app that runs if no custom app is registered
- Android manifest and resources
ratadroid runThis builds the Rust library, builds the APK, installs it on a connected device (or starts an emulator), and launches it.
ratadroid run --logStreams colorized logcat output after launching the app. Press Ctrl+C to stop.
Scaffold a new Android NativeActivity project.
ratadroid new my-appBuild the Android project using Gradle.
ratadroid build # Debug build
ratadroid build --variant release # Release buildInstall the APK on a connected device or emulator. Prefers physical devices over emulators.
ratadroid installBuild, install, and launch the app. If no device is connected, attempts to start an available emulator.
ratadroid run # Build and run
ratadroid run --log # Build, run, and stream logcatNote: Emulator auto-start waits for boot completion, which can take 30-120 seconds.
List all available Android devices and emulators.
ratadroid devicesShow crash logs and errors from the app.
ratadroid logs
ratadroid logs --lines 200Check your development environment and optionally fix issues.
ratadroid doctor
ratadroid doctor --fixServe APKs over HTTP for easy installation on devices. Auto-detects APK output directory if dist/ doesn't exist.
ratadroid serve # Auto-detects app/build/outputs/apk/
ratadroid serve --port 9000 # Custom portmy-app/
├── app/
│ ├── build.gradle
│ └── src/main/
│ ├── AndroidManifest.xml
│ ├── java/com/ratadroid/my_app/NativeActivity.java
│ └── res/
├── ratatui-android/ # Ratatui Android runtime library
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs # Public API
│ ├── backend.rs # Ratatui backend
│ ├── rasterizer.rs # Software rasterizer
│ ├── input.rs # Input handling
│ └── widgets/ # Custom widgets
├── rust/
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs # Main entry point
│ ├── runtime.rs # Android runtime loop
│ └── demo.rs # Demo app
├── build.gradle
├── settings.gradle
└── gradlew
The scaffolded projects include a Ratatui Android Runtime:
- Direct surface rendering - Renders Ratatui cells directly to Android surfaces
- System fonts - Uses Android system fonts by default (RobotoMono, DroidSansMono, etc.)
- Touch input - Maps Android touch events to Ratatui mouse events
- Keyboard input - Keyboard support with international character handling
- Orientation support - Handles screen rotation
- System UI padding - Reserves space for status bar and navigation bar
- Font rendering uses system fonts - not all Unicode characters may render perfectly
- Some input edge cases exist - international keyboard support works but may need refinement
- Software rasterization is CPU-intensive - may struggle on older devices
- Soft keyboard may not appear reliably on all devices/Android versions
- Some Ratatui widgets may not work perfectly - this is a custom backend
Edit the Rust code to customize:
rust/src/lib.rs- Main app registration and setuprust/src/demo.rs- Demo app implementationratatui-android/src/- Runtime implementation
- Create project:
ratadroid new my-app - Edit code: Modify
rust/src/files - Build and test:
ratadroid run --log - Iterate
- Ensure you're in a project directory created with
ratadroid new - Check that
cargo-ndkis installed:cargo install cargo-ndk - Verify Android SDK/NDK paths with
ratadroid doctor
- Connect a device via USB with USB debugging enabled
- Or create an AVD in Android Studio first
- Check with
ratadroid devices
- Use debug builds:
ratadroid run --variant debug - Check device settings for "Install unknown apps" permission
- Use
ratadroid run --logto see crash details in real-time - Or check
ratadroid logsafter the crash
Emulator boot can take 1-2 minutes. The tool waits for boot completion automatically. Use a physical device for faster iteration.
Builds for:
arm64-v8a(64-bit ARM) - most modern phonesarmeabi-v7a(32-bit ARM) - older phones
Both architectures are built by default.
MIT License. See LICENSE for details.
