mozilla / rust-android-gradle

Apache License 2.0
1.03k stars 67 forks source link

compile failed with -target=aarch64-linux-android #124

Closed tyrionchen closed 1 year ago

tyrionchen commented 1 year ago

Why am I able to successfully compile when I run cargo build in the rust directory, but it fails when I add --target=aarch64-linux-android? Here are the steps I took:

git clone git@github.com:mozilla/rust-android-gradle.git rustup target add aarch64-linux-android cd rust-android-gradle/samples/rust

and this compiled successfully: cargo build

image

this compiled failed: cargo build --target=aarch64-linux-android

image

The error message told me that target aarch64-linux-android is not installed, but I have already installed it.

image
ncalexan commented 1 year ago

I suggest running Gradle with --info or --verbose. Then you should be able to see the full cargo command lines executed. My guess is that Gradle is finding a different installation than that on your shell path, but there's only one way to find out.

tyrionchen commented 1 year ago

I suggest running Gradle with --info or --verbose. Then you should be able to see the full cargo command lines executed. My guess is that Gradle is finding a different installation than that on your shell path, but there's only one way to find out.

Thanks for @ncalexan 's reply. The cause of this issue has been identified, and I will close this issue for now. Let me explain. I initially discovered this issue when I failed to build the cargo module using the org.mozilla.rust-android-gradle.rust-android plugin. After analyzing the code, I found that it would always fail as long as we ran "cargo build" with the "--target" parameter. So I raised this question on URLO and eventually got some help, which helped me solve the problem. For those who encounter this issue, you can refer to this link: https://users.rust-lang.org/t/compile-failed-with-target-aarch64-linux-android/92439

tyrionchen commented 1 year ago

I suggest running Gradle with --info or --verbose. Then you should be able to see the full cargo command lines executed. My guess is that Gradle is finding a different installation than that on your shell path, but there's only one way to find out.

thanks @ncalexan, you are right

ncalexan commented 1 year ago

Glad you got to the bottom of things, and thanks for the helpful link to the thread where you resolved the issue!