Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'x86_64' #47

Closed
snazhmudinov opened this issue Jul 16, 2022 · 10 comments

Comments

@snazhmudinov
Copy link

Machine setup:
macOS Monterey 12.4

Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+0-b1504.28-7817840 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

bazel version installed: 5.0.2

I'm getting familiarized with Bazel, and trying to sync the small Android project in AS.
Tutorial: https://bazel.build/tutorials/android-app

However, when I sync via AS UI, I get the following error:

Error:(48, 19) in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'x86_64'

I have no issue building and deploying the app via the terminal.

Can someone please explain what I'm doing wrong? Thanks.

@snazhmudinov
Copy link
Author

Downgrading/upgrading the bazel verion (via bazelisk) didn't work.

@arunkumar9t2
Copy link

It is possible AS is using different bazel version. Have you configured the bazel binary path in AS settings to use bazelisk?

@snazhmudinov
Copy link
Author

i changed the bazel binary location to point to bazelisk, and it still gives the error :(
Screen Shot 2022-07-17 at 10 42 23 AM

@arunkumar9t2
Copy link

Also worth running clean ——expunge to force toolchain resolution to run again.

@snazhmudinov
Copy link
Author

Tried clean --expunge as well, it didn't really help.
I'm fairly new to bazel, so at this point I wasn't sure how to proceed.

@ahumesky
Copy link
Collaborator

ahumesky commented Aug 31, 2022

If you're still running into this problem, and if your app has native dependencies (e.g. cc_library), it might be that there needs to be an android_ndk_repository rule in your WORKSPACE file:

android_ndk_repository(
  name = "androidndk",
)

and set the ANDROID_NDK_HOME environment variable to the path of a locally installed NDK (up to r21 is supported, see bazelbuild/bazel#12889)

@ted-xie
Copy link
Contributor

ted-xie commented Dec 19, 2022

@snazhmudinov Still running into this issue?

@omrta-dev
Copy link

Not OP but I was able to resolve the issues by using r25 for the ndk instead of r21

@ted-xie
Copy link
Contributor

ted-xie commented Apr 6, 2023

If people are still running into this, I'd suggest upgrading Bazel versions to 6.0.0 or higher and seeing if the problem persists, and if you're using a newer NDK version, to use https://github.com/bazelbuild/rules_android_ndk in place of the native android_ndk_repository.

I think it would be prudent to close out this bug, since there seem to be multiple solutions/workarounds, and little activity in this thread. I'll circle back in a week and close this out if there are no objections.

@snazhmudinov
Copy link
Author

Sorry for the silence. I will check with the new bazel version. Meanwhile I'm closing this issue. Thank you!

ted-xie pushed a commit to ted-xie/rules_android that referenced this issue Jul 16, 2024
Adding support for Bzlmod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants