How to make IntelliJ compile like `cargo ndk ...`?

โš“ Rust    ๐Ÿ“… 2025-09-18    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 2      

surdeus

Iโ€™m trying to build an app for various platforms. For Android, I use this command line:

cargo ndk -t arm64-v8a -o ./MyAndroidApp/app/src/main/jniLibs build -p my-app --lib

That works great. It comes from cargo install cargo-ndk. It builds a .so library and I then use Android Studio to complete the app. But if I make the mistake of clicking Run or Build in IntelliJ (my Rust IDE) instead of Android Studio, then it does something to wipe the build results. Even if I kill it, if I then go back to cargo ndk โ€ฆ, the cargo command rebuilds everything.

Itโ€™s an annoyance. I wonder if there is a way, when Iโ€™m working on Android, to tell IntelliJ about this cargo ndk โ€ฆ command.

IntelliJ does see my .cargo/config.toml with the line:

target = "aarch64-linux-android"

And that causes IntelliJ to display sections marked #[cfg(target_os = โ€œandroidโ€)] as active, which is nice, the build command still seems to be incompatible.

1 post - 1 participant

Read full topic

๐Ÿท๏ธ Rust_feed