android-build
Use this crate from your Cargo build.rs
build script to compile Java source files and to run Java/Android commands as part of a Rust build,
specifically designed for Android-targeted builds and Android tools.
This crate aims to behave similarly to cc-rs
, but for Java (primarily on Android) instead of C/C++.
This crate is part of Project Robius and is primarily used by those crates.
Usage
Add this crate as a build dependency to your Cargo.toml
:
[]
= "0.1.0"
Then add this to your build.rs
build script:
The above code will automatically run when you build your crate using cargo build
.
Configuration via environment variables
The crate-level documentation provides a detailed list of environment variables that can be set to configure this crate.
Examples
Check out the robius-authentication
build script to see how we use this crate for more complicated build procedures:
- Discovering specific Android jarfiles and SDK directories (platforms, build tools, etc).
- Compiling Java classes against the main
android.jar
jarfile. - Invoking Android's
d8
DEXer tool.