Skip to content
forked from bbqsrc/cargo-ndk

Compile Rust projects against the Android NDK without hassle

License

Notifications You must be signed in to change notification settings

ScSofts/cargo-ndk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cargo-ndk - Build Rust code for Android

This cargo extension handles all the environment configuration needed for successfully building libraries for Android from a Rust codebase.

Installing

cargo install cargo-ndk

You'll also need to install all the toolchains you intend to use. Simplest way is with the following:

rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android 

Usage

You'll also need the NDK installed somewhere, and the path to it exported as the ANDROID_NDK_HOME environment variable. If you use Android Studio and have ANDROID_SDK_HOME defined, cargo ndk is smart enough to detect the ndk-bundle subdirectory as well.

Building is very similar to any other Rust project, with the addition of the --platform flag for selecting which Android API platform to target. By default, 21 is a good choice.

cargo ndk --platform 21 --target x86_64-linux-android build

Add --release for a release build, as per usual.

NOTE: Minimum supported NDK version is r19c. Has been tested up to r21.

Supported triples

  • aarch64-linux-android
  • armv7-linux-androideabi
  • i686-linux-android
  • x86_64-linux-android

Supported hosts

  • Linux
  • macOS
  • Windows

Similar projects

  • cargo-lipo - for building iOS universal Rust libraries

License

This project is licensed under either of

at your option.


Uyghurs are under attack in Xinjiang. The Chinese government is placing millions of people into indoctrination camps and engaging in forced labour.

About

Compile Rust projects against the Android NDK without hassle

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%