I’m working on an Android app built with Kotlin in Android Studio, and I’m trying to integrate a Rust library into my project. The Rust library has a dependency on OpenSSL. When I attempt to compile the Rust library with the x86_64-linux-android
target, I encounter the following error:
error: failed to run custom build command for `ring v0.17.8`
Caused by:
process didn't exit successfully: `C:<PROJECT-PATH>appsrcmainrusttargetdebugbuildring-52324e4519f4905abuild-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_8_
OPT_LEVEL = Some(0)
TARGET = Some(x86_64-linux-android)
OUT_DIR = Some(C:<PROJECT-PATH>appsrcmainrusttargetx86_64-linux-androiddebugbuildring-ae4372e2a1fc0bf3out)
HOST = Some(x86_64-pc-windows-msvc)
cargo:rerun-if-env-changed=CC_x86_64-linux-android
CC_x86_64-linux-android = None
cargo:rerun-if-env-changed=CC_x86_64_linux_android
CC_x86_64_linux_android = None
cargo:rerun-if-env-changed=TARGET_CC
TARGET_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:warning=Compiler family detection failed due to error: ToolNotFound: Failed to find tool. Is `x86_64-linux-android-clang` installed? (see https://github.com/rust-lang/cc-rs#compile-time-requirements for help)
...
The error seems to be related to the ring
crate, which is a dependency of OpenSSL. The issue appears to be that the compiler cannot find the x86_64-linux-android-clang
tool, which is required for compiling the ring
crate for the x86_64-linux-android
target.
If I remove the OpenSSL dependency from my Rust library, the compilation succeeds without any issues.
I’ve tried searching for solutions, but I haven’t found a clear answer on how to resolve this issue. I’m using the following versions:
- Cargo: 1.79.0
- Rustup: 1.27.1
- Android Studio: Koala
- Kotlin: 1.8 / Java 17
- LLVM 18.1.6
Question: How can I resolve this issue and successfully compile my Rust library with the OpenSSL dependency for the x86_64-linux-android
target?
Ken Schueman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.