/rust-android-sample

This repository shows how we can use Rust to build Android apps/libraries.

Primary LanguageKotlinApache License 2.0Apache-2.0

rust-android-sample

This is a sample app that shows how we can use Rust programming language to build shared code that can be used by Android apps. This project is based in the mozilla/rust-android-gradle plugin, specifically in its app sample.

What does this sample do?

In this sample we build a very small Rust library and a very simple Kotlin Android app that uses that library. The app just call the Rust library and gets a result back using callback

App scenarios

How to build and deploy?

  1. Follow the Get started section from the Rust main site.
  2. Clone the repo, and open it in Android Studio.
  3. Install all the specific toolchains that you will need/use. Find more info here.
  4. Click on build/deploy app. It should automatically build and deploy in an emulator/device.

If you are in Windows and you find some issues when building about not able to find lgcc, please, have a look to this issue. I followed this hack and it works. At least is good enough till this issue is fixed.

If you want just to create your own app using the rust-android-gradle plugin, follow its README instructions.

Useful resources

  1. Get started with Rust.
  2. Rust language reference.
  3. Building and deploying a Rust library on Android.
  4. Rust on Android + its sample code.
  5. Rust-Android-Gradle plugin and its samples.
  6. Crate JNI (note: as writing this latest is 0.19.0).
  7. The Manifest format.
  8. If you found issues when using NDK >= 23, please check this.
  9. How to fix NDK is not installed issue. Please, read this.
  10. If you find issues when using NDK >- 23 on Windows complaining about not finding lgcc library, please, read this.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

License

Based in rust-android-gradle plugin samples under Apache License v2.