pytorch / pytorch/executorch

[Android] Honor standard SDK environment variables in build_android_library.sh

Open
#22,682 0 comments 0 reactions 2 assignees View on GitHub

@kirklandsign is already working on this.

Since Sep 10, 2026.

bug module: android module: build/install
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

Problem

scripts/build_android_library.sh currently derives Gradle ANDROID_HOME only from ANDROID_SDK, with /opt/android/sdk as the fallback. GitHub Android runners and many developer environments set ANDROID_HOME or ANDROID_SDK_ROOT instead, so the script can ignore the configured SDK and point Gradle at the wrong path.

This was found while validating the Android documentation in #22620. The implementation change is intentionally excluded from that documentation-only PR.

Proposed change

Resolve the SDK path from ANDROID_SDK, then ANDROID_HOME, then ANDROID_SDK_ROOT, with the existing fallback. Pass the resolved path to Gradle through both standard variables.

Test plan
  • Exercise the script with each supported environment variable independently.
  • Run the Android AAR build job.
  • Run the Android emulator integration job.

cc @larryliu0820 @GregoryComer @kirklandsign @cbilgin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.