An example app showing the integration of Rust Tokio.rs with Android
and it uses an event-based bridge for two-way communication
. It allows you
to write async rust code (thanks to Tokio.rs runtime) in Android
for better performance and it can also be used as a worker alternative of Java thread pool
.
It creates a bridge wrapper between Java
and Rust
environment so that you don't have to deal with jni-rs
frequently.
It's using tusk to run the automated scripts. Install it from the following:
brew install rliebz/tusk/tusk
Setup the project by installing all the required dev tools:
tusk setup
Start the dev hot rebuild process:
tusk dev
Build release library files:
tusk build:prod
Generate jni files:
tusk jni
See logcat via ADB
:
tusk log
Please refer to tusk.yml
file for more commands.
-
For more info.
-
Array signature encoding: https://stackoverflow.com/questions/28780623/sending-jbyte-array-to-java-method-failed-using-jni
-
Cache the method id or field id to call a method or to access a field repeatedly from java object for better performance: https://docs.oracle.com/en/java/javase/11/docs/specs/jni/design.html#accessing-fields-and-methods