- Raw FFI bindings to the NDK
- Safe abstraction of the bindings
- Startup code
- Everything for building apk"s
- Build tool
Cargo.toml
[lib]
crate-type = ["lib", "cdylib"]
Wraps main
function using attribute macro ndk::glue::main
:
src/lib.rs
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace))]
pub fn main() {
println!("hello world");
}
src/main.rs
fn main() {
$crate::main();
}
cargo install cargo-apk
cargo apk run
Stdout is redirected to the android log api when using ndk-glue
. Any logger that logs to
stdout should therefore work.
Android logger can be setup using feature "logger" and attribute macro like so:
src/lib.rs
#[cfg_attr(target_os = "android", ndk_glue::main(logger(debug, "my-tag")))]
pub fn main() {
println!("hello world");
}
TODO: talk more about jni and add some examples
jni
, JNI bindings for Rust
TODO shameless plug
TODO shameless plug