Skip to content

rousan/AndroidWithRust

Repository files navigation

Android with Rust

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.

Requirements

It's using tusk to run the automated scripts. Install it from the following:

brew install rliebz/tusk/tusk

Development

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.

Reference links

  1. For more info.

  2. Array signature encoding: https://stackoverflow.com/questions/28780623/sending-jbyte-array-to-java-method-failed-using-jni

  3. 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

About

An example Android app showing two-way communication bridge with Rust backed by Tokio.rs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published