I'm working on a project that uses Flutter and Rust, and I'm trying to build it for Android. However, I'm facing an error related to arm-linux-androideabi-ranlib
not being found. Here's the error message I'm getting:
--- stderr
/home/user/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar: warning: creating libcrypto.a
/bin/sh: 1: arm-linux-androideabi-ranlib: not found
/home/user/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar: warning: creating libssl.a
/bin/sh: 1: arm-linux-androideabi-ranlib: not found
/bin/sh: 5: arm-linux-androideabi-ranlib: not found
make: *** [Makefile:313: install_dev] Error 127
thread 'main' panicked at '
Error installing OpenSSL:
Command: cd "/home/user/IdeaProjects/my_project/rust/target/armv7-linux-androideabi/debug/build/openssl-sys-c3d36b893b4843b2/out/openssl-build/build/src" && "make" "install_dev"
Exit status: exit status: 2
I've checked the NDK directory, and it seems like the required tools are present but not exactly the file arm-linux-androideabi-ranlib
. Here's the output of ls for the toolchain directory:
prebuilt/linux-x86_64/bin via π v2.7.18 took 6s
β― pwd
/home/user/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bi
prebuilt/linux-x86_64/bin via π v2.7.18
β― ls
aarch64-linux-android21-clang i686-linux-android29-clang++
aarch64-linux-android21-clang++ i686-linux-android30-clang
aarch64-linux-android22-clang i686-linux-android30-clang++
aarch64-linux-android22-clang++ i686-linux-android31-clang
aarch64-linux-android23-clang i686-linux-android31-clang++
aarch64-linux-android23-clang++ i686-linux-android32-clang
aarch64-linux-android24-clang i686-linux-android32-clang++
aarch64-linux-android24-clang++ i686-linux-android33-clang
aarch64-linux-android26-clang i686-linux-android33-clang++
aarch64-linux-android26-clang++ ld
aarch64-linux-android27-clang ld64.lld
aarch64-linux-android27-clang++ ld.lld
aarch64-linux-android28-clang lld
aarch64-linux-android28-clang++ lldb
aarch64-linux-android29-clang lldb-argdumper
aarch64-linux-android29-clang++ lldb.sh
aarch64-linux-android30-clang lld-link
aarch64-linux-android30-clang++ llvm-addr2line
aarch64-linux-android31-clang llvm-ar
aarch64-linux-android31-clang++ llvm-as
aarch64-linux-android32-clang llvm-bolt
aarch64-linux-android32-clang++ llvm-cfi-verify
aarch64-linux-android33-clang llvm-config
aarch64-linux-android33-clang++ llvm-cov
armv7a-linux-androideabi19-clang llvm-cxxfilt
armv7a-linux-androideabi19-clang++ llvm-dis
armv7a-linux-androideabi21-clang llvm-dwarfdump
armv7a-linux-androideabi21-clang++ llvm-dwp
armv7a-linux-androideabi22-clang llvm-lib
armv7a-linux-androideabi22-clang++ llvm-link
armv7a-linux-androideabi23-clang llvm-lipo
armv7a-linux-androideabi23-clang++ llvm-modextract
armv7a-linux-androideabi24-clang llvm-nm
armv7a-linux-androideabi24-clang++ llvm-objcopy
armv7a-linux-androideabi26-clang llvm-objdump
armv7a-linux-androideabi26-clang++ llvm-profdata
armv7a-linux-androideabi27-clang llvm-ranlib
armv7a-linux-androideabi27-clang++ llvm-rc
armv7a-linux-androideabi28-clang llvm-readelf
armv7a-linux-androideabi28-clang++ llvm-readobj
armv7a-linux-androideabi29-clang llvm-size
armv7a-linux-androideabi29-clang++ llvm-strings
armv7a-linux-androideabi30-clang llvm-strip
armv7a-linux-androideabi30-clang++ llvm-symbolizer
armv7a-linux-androideabi31-clang llvm-windres
armv7a-linux-androideabi31-clang++ merge-fdata
armv7a-linux-androideabi32-clang remote_toolchain_inputs
armv7a-linux-androideabi32-clang++ sancov
armv7a-linux-androideabi33-clang sanstats
armv7a-linux-androideabi33-clang++ scan-build
bisect_driver.py scan-view
clang x86_64-linux-android21-clang
clang++ x86_64-linux-android21-clang++
clang-14 x86_64-linux-android22-clang
clang-check x86_64-linux-android22-clang++
clangd x86_64-linux-android23-clang
clang-format x86_64-linux-android23-clang++
clang-tidy x86_64-linux-android24-clang
dsymutil x86_64-linux-android24-clang++
git-clang-format x86_64-linux-android26-clang
i686-linux-android19-clang x86_64-linux-android26-clang++
i686-linux-android19-clang++ x86_64-linux-android27-clang
i686-linux-android21-clang x86_64-linux-android27-clang++
i686-linux-android21-clang++ x86_64-linux-android28-clang
i686-linux-android22-clang x86_64-linux-android28-clang++
i686-linux-android22-clang++ x86_64-linux-android29-clang
i686-linux-android23-clang x86_64-linux-android29-clang++
i686-linux-android23-clang++ x86_64-linux-android30-clang
i686-linux-android24-clang x86_64-linux-android30-clang++
i686-linux-android24-clang++ x86_64-linux-android31-clang
i686-linux-android26-clang x86_64-linux-android31-clang++
i686-linux-android26-clang++ x86_64-linux-android32-clang
i686-linux-android27-clang x86_64-linux-android32-clang++
i686-linux-android27-clang++ x86_64-linux-android33-clang
i686-linux-android28-clang x86_64-linux-android33-clang++
i686-linux-android28-clang++ yasm
i686-linux-android29-clang
I'm using Flutter 3.7.6, Dart 2.19.3, and cargo-ndk. My gradle.properties file has the ANDROID_NDK variable set to the correct path:
ANDROID_NDK=/home/user/Android/Sdk/ndk/25.2.9519653/
In my build.gradle
, I have the following tasks for building the Rust project:
[
new Tuple2('Debug', ''),
new Tuple2('Profile', '--release'),
new Tuple2('Release', '--release')
].each {
def taskPostfix = it.first
def profileMode = it.second
tasks.whenTaskAdded { task ->
if (task.name == "javaPreCompile$taskPostfix") {
task.dependsOn "cargoBuild$taskPostfix"
}
}
tasks.register("cargoBuild$taskPostfix", Exec) {
commandLine 'sh', '-c', """cd ../../rust/my_lib && \
ANDROID_NDK_HOME="$ANDROID_NDK" cargo ndk \
-t armeabi-v7a -t arm64-v8a -t x86 -t x86_64 \
-o ../android/app/src/main/jniLibs build $profileMode"""
}
}
And I'm using flutter_rust_bridge version 1.67.0 in my project. Doc related to build.gradle
file here.
Rust Cargo.toml
:
[lib]
crate-type = ["lib", "staticlib", "cdylib"]
[dependencies]
openssl = { version = "0.10", features = ["vendored"] }
Does anyone have any idea why the build is failing with the "arm-linux-androideabi-ranlib not found" error and how to fix it? Any help would be appreciated. Thanks!
arm-linux-androideabi-ranlib
exist. β Kittiekittiwakeaarch64-linux-android-ranlib: not found
(probably just due to the build order). β Gradate