Magisk

Building and Development

Setup Environment

Building

IDE Support

Developing Rust

First, install rustup, the official Rust toolchain manager. The Magisk NDK package ONDK (the one installed with ./build.py ndk) bundles a complete Rust toolchain, so building the Magisk project itself does not require any further configuration.

However, if you’d like to work on the Rust codebase, it’ll be easier if you link ONDK’s Rust toolchain in rustup and set it as default so several development tools and IDEs will work properly:

# Link the ONDK toolchain with the name "magisk"
rustup toolchain link magisk "$ANDROID_HOME/ndk/magisk/toolchains/rust"
# Set magisk as default
rustup default magisk

If you plan to use VSCode, you can then install the rust-analyzer plugin and everything should be good to go. If you plan to use Jetbrain IDEs (e.g. Rustrover, or its Rust Plugin), we need some additional setup:

rustup toolchain install nightly
# Add some components that is also included in ONDK
rustup +nightly component add rust-src clippy
# We choose ~/.cargo/wrapper here as an example (and a good recommendation)
# Pick any path you like, you just need to use this path in the next step
./build.py rustup ~/.cargo/wrapper

Signing and Distribution