[BUG]: Linux - No matching toolchains found During Bazel sync
Describe the bug
While attempting to sync the full project using the Bazel plugin, multiple error logs appear: No matching toolchains found for types @bazel_tools//tools/android:sdk_toolchain_type
This indicates that the IDE or the Bazel plugin is attempting to build an Android target but cannot locate a proper Android SDK toolchain, as they can't detect the $ANDROID_HOME configuration correctly.
Steps To Reproduce
- Follow the Installing Oppia Android Wiki guide for Linux
- Ensure the
ANDROID_HOMEenvironment variable is correctly set by running:echo $ANDROID_HOME - Open the project in Android Studio.
- Click on "Sync Project with BUILD files" button of Bazel plugin in the top-right corner of the IDE.
- Observe the following errors in the log:
While resolving toolchains for target //...: No matching toolchains found for types @bazel_tools//tools/android:sdk_toolchain_type.
Expected Behavior
The project should sync successfully without any missing toolchain errors.
Screenshots/Videos
Additional Context
The issue has been reported by Linux users using Android Studio Giraffe.
Workaround
- Hardcoding the Android SDK path in the Bazel
WORKSPACEfile usingandroid_sdk_repositoryresolves the issue and allows the sync to complete successfully. - Another workaround to avoid hardcoding, is launching Android Studio from the terminal to let it inherit the terminal environment
- Navigate to the Android Studio
bindirectory in the terminal - Run
./studio.sh - The Bazel sync should run successfully.
- Navigate to the Android Studio
//assign me this task
Hi @itsadityaaaaa, please provide a summary of your proposed solution to this, and any other issues you are interested in working on. We can help hammer out the details to make it easier to get started. Also, have you taken a look at our starter issues?
Hi @adhiamboperes actually I recently built the oppia android and faced similar type of issue it can be fixed using the steps given in troubleshoot installation that include adding some packages in BUILD.bazel and creating file MODULE.bazel
Thanks for your recommendation of starter issues, I will definitely try to fix some of them.
@itsadityaaaaa, could you please clarify what you mean by:
adding some packages in BUILD.bazel and creating file MODULE.bazel
Write now not fully sure about the solution I linked it with a similar issue I encountered during my installation some information about the error is given in troubleshoot section of installation guide. Hardcode the Android Sdk path in Workspace work for me, Required your further guidance
Thanks @itsadityaaaaa. Hardcoding the Android SDK path in the Bazel WORKSPACE is a workaround, but not a permanent fix. We would like to investigate other alternative fixes that can solve this issue. To do that, we need to understand why setting tthe $ANDROID_HOME in the .bashrc file is not working on Ubuntu, but working fine on other operating systems.