oppia-android icon indicating copy to clipboard operation
oppia-android copied to clipboard

[BUG]: Linux - No matching toolchains found During Bazel sync

Open manas-yu opened this issue 6 months ago • 7 comments

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_HOME environment 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

Image

Additional Context

The issue has been reported by Linux users using Android Studio Giraffe.

Workaround

  • Hardcoding the Android SDK path in the Bazel WORKSPACE file using android_sdk_repository resolves 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 bin directory in the terminal
    • Run ./studio.sh
    • The Bazel sync should run successfully.

manas-yu avatar May 27 '25 18:05 manas-yu

//assign me this task

itsadityaaaaa avatar May 28 '25 11:05 itsadityaaaaa

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?

adhiamboperes avatar May 28 '25 11:05 adhiamboperes

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

itsadityaaaaa avatar May 28 '25 11:05 itsadityaaaaa

Thanks for your recommendation of starter issues, I will definitely try to fix some of them.

itsadityaaaaa avatar May 28 '25 11:05 itsadityaaaaa

@itsadityaaaaa, could you please clarify what you mean by:

adding some packages in BUILD.bazel and creating file MODULE.bazel

adhiamboperes avatar May 30 '25 08:05 adhiamboperes

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

Image

itsadityaaaaa avatar May 30 '25 14:05 itsadityaaaaa

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.

adhiamboperes avatar Jun 02 '25 21:06 adhiamboperes