install Android Studio from https://developer.android.com/studio
the NDK is necessary to provide an LLVM toolchain for compiling native binaries for Android devices. the NDK can be downloaded from the SDK manager within Android Studio.
Note the installed version and install location.
https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs
static library objects need to be copied to the Android project at:
<app_root>/src/main/jniLibs
- x86
- x86_64
- armeabi
- armeabi-v7a
- arm64-v8a
this project requires the rustup
and cargo
tools to be installed. they can be installed from https://www.rust-lang.org/tools/install i.e.:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add aarch64-linux-android armv7-linux-androideabi
create a cargo config file at ~/.cargo/config
:
android_sdk
is the install location of the Android SDKhost-os
is the architecture of the compiler on the host system. it should be the only one installed by defaultndk_version
is the version of the installed NDK from the SDK manager- other ABIs will need to be added if you want to support those architectures
[target.aarch64-linux-android]
linker = "<android_sdk>/ndk/<ndk_version>/toolchains/llvm/prebuilt/<host-os>/bin/aarch64-linux-android30-clang++"
[target.armv7-linux-androideabi]
linker = "<android_sdk>/ndk/<ndk_version>/toolchains/llvm/prebuilt/<host-os>/bin/armv7a-linux-androideabi30-clang++"
building and copying of the Rust binaries is automated by gradle. tasks were added that build, copy, and cleanup libraries for supported ABIs. these tasks are executed automatically for build and clean tasks.
building the app including the static object binaries is as easy as clicking run in Android Studio or simply running ./gradlew build
.