#android #so #ndk #jni

app cargo-so

Helps cargo build Android .so lib files

5 releases

0.2.0 Aug 19, 2023
0.1.3 Oct 13, 2022
0.1.2 Jan 24, 2022
0.1.1 Jan 21, 2022
0.1.0 Jan 21, 2022

#277 in Cargo plugins

Download history 3/week @ 2023-11-04 2/week @ 2023-11-11 4/week @ 2023-11-18 30/week @ 2023-11-25 5/week @ 2023-12-02 12/week @ 2023-12-09 2/week @ 2023-12-16 14/week @ 2023-12-23 7/week @ 2023-12-30 7/week @ 2024-01-06 3/week @ 2024-01-13 7/week @ 2024-01-20 22/week @ 2024-01-27 4/week @ 2024-02-03 24/week @ 2024-02-10 84/week @ 2024-02-17

135 downloads per month

MIT/Apache

7KB
74 lines

cargo so

Tool for compile Rust package to Android .so lib files. Code modified from cargo-apk

Installation

cargo install --path .

Usage

Assuming your computer already has Android Studio installed, go to Android Studio > Tools > SDK Manager > Android SDK > SDK Tools. Check the following options for installation and click OK.

  • Android SDK Build-Tools
  • Android SDK Command-line Tools
  • NDK(Side by side)

Set two following environment variables:

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
# Replace the NDK version number with the version you installed 
export NDK_HOME=$ANDROID_SDK_ROOT/ndk/23.1.7779620

Add build targets

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

Build

# build to all android targets
cargo so build --lib 
# build to the specified target
cargo so b --lib --target aarch64-linux-android

Dependencies

~5–15MB
~184K SLoC