Skip to content

Conversation

@breautek
Copy link
Contributor

Platforms affected

Android/All OS

Motivation and Context

Fixes #1841

Description

This PR does two things:

  1. Introduces AndroidCommandLineTools module, whose primary purpose is to find the toolsets available in the workstation and to resolve the latest bin path.

The resolving algorithm will prefer the "latest" (a specific Android SDK package that installs the cmdline tools to a latest directory), however if this package is not installed, it will choose the latest stable versioned cmdline-tools, e.g. 19.0. It uses semver to coarce the directory names and sort them in descending order.

Prelease packages are acceptable but prioritized lower than stable releases of the same version.

Directories that are not parseable as a version are ignored.

Directories that are valid name wise are not asserted for it's contents and assumes that it's structure matches what is expected based on Android SDK cmdline-tools installation.

  1. Removes references and usages of the legacy $ANDROID_HOME/tools/bin binaries. These are legacy tools that are not compatible with modern toolsets. The cmdline-tools is the replacement. There is existing code that would infer the Android SDK home directory based on the result of which of avdmanager

Additional Notes

The cmd-line tools resolution prefers the latest cmdline-tools version possible because that is what our guide says to install. However cmdline-tools can introduce breaking changes. Typically in the java runtime required to run these tools.

It would be better if we define a version or a range of versions for Cordova CLI to prefer, but doing so I'd consider out of scope for addressing the reported issue.

Testing

npm test passes.
Manually tested on windows using cordova requirements android / cordova build android:

  • With ANDROID_HOME / ANDROID_SDK_ROOT set
  • With ANDROID_HOME / ANDROID_SDK_ROOT unset
  • With avdmanager in my PATH
  • With avdmanager not in my PATH
  • With Android SDK in the "default" windows installation (C:\users\asdf\AppData\Local\Android...)
  • With Android SDK installed in a custom location
  • Some sort of combination of all the above.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link

codecov-commenter commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 92.92035% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.39%. Comparing base (6b76757) to head (37cb8e1).

Files with missing lines Patch % Lines
lib/env/AndroidCommandLineTools.js 92.15% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1877      +/-   ##
==========================================
+ Coverage   60.77%   61.39%   +0.62%     
==========================================
  Files          23       24       +1     
  Lines        4813     4919     +106     
==========================================
+ Hits         2925     3020      +95     
- Misses       1888     1899      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks OK to me.

I just added a few nitpicks 😄

I've been updating license headers across the board to follow a consistent pattern for the various file types.

@breautek breautek merged commit 76bac55 into apache:master Dec 18, 2025
11 checks passed
@breautek breautek deleted the fix-requirements branch December 18, 2025 13:23
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

Successfully merging this pull request may close these issues.

avdmanger doesnt exists in android_home/tools/bin

4 participants