Home

Awesome

Oxidized NDK

This is not an officially supported Google product.

Oxidized NDK (ONDK) is an unofficial repackaged Android NDK that includes a Rust toolchain. This repository hosts build scripts to build and package ONDK using GitHub Actions. Every file included in the final package either originates from the official NDK zip or is built in GitHub Actions.

This project does not include or attempt to do any modifications to Rust and LLVM.<br> This project is for experimental purposes, and does not guarantee any Android NDK or Rust functionality.<br> Use at your own risk.

Download the latest ONDK in releases.

Supports all NDK host platforms:<br> Linux (x64), Windows (x64), and macOS (x64 + arm64, universal binaries).

How to Use

For building C/C++ code, ONDK is just like any ordinary Android NDK, no special configurations are needed.

For building Rust code, link ONDK's Rust toolchain with rustup:

rustup toolchain link <name> <ondk>/toolchains/rust

The std crate is intentionally not prebuilt and included in ONDK, so building requires a little bit of setup.<br> Here is an example for building a project targeting API 21 for ARM64:

LLVM_BIN="<ondk>/toolchains/llvm/prebuilt/<os>-x86_64/bin"

# We need to tell cargo where to find the NDK linker for Android.
# You can also set this in config.toml, check the official documentation.
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$LLVM_BIN/aarch64-linux-android21-clang"

# Finally, build our project with -Z build-std
cargo <+name> build -Z build-std --target aarch64-linux-android

P.S. I strongly recommend checking out min-sized-rust to minimize Rust binaries.

How ONDK is Built

FAQ

License

Copyright 2022-2024 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.