Open 9ary opened 3 years ago
I'm looking into this
re: supported versions, this is a useful thing to keep in mind:
Figure out how to integrate Rust into an Android project
https://github.com/Dushistov/flapigen-rs https://github.com/jni-rs/jni-rs https://github.com/rust-windowing/android-ndk-rs/blob/fe3576c8d8a5b54f09475dcb0bb530e56df60eb1/ndk-examples/examples/jni_audio.rs
https://github.com/Dushistov/flapigen-rs/issues/277 https://stackoverflow.com/questions/61220627/rust-jni-async-callback-with-tokio-and-reqwest-for-android
https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html mentions API layer 26 so we might want to go with that.
https://robertohuertas.com/2019/10/27/rust-for-android-ios-flutter/ details making an Android Library (2019)
See branch https://github.com/9ary/talaria/tree/rust-jni.
To run, you need to run scripts/android_build.sh
and then run in Android Studio (we could integrate this into a cargo or gradle workflow)
Prerequisites:
Install the Android SDK/NDK (and set ANDROID_NDK_HOME if it's not the default location)
cargo install cargo-ndk
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
Now that I've been experimenting with Jetpack Compose and the jni crate, it's clear that debugging the rust calls is a pain point. Redirecting stdout/stderr would be a good start, and some logging and backtraces would help a lot too. https://crates.io/crates/ndk seems to have a lot of nice features in this area (and other jni annoyances) but I'm not sure if it will integrate with Compose.
The Android version is a solid choice for the MVP.