Skip to content

fix: detect SDK packages from Android CLI output - #309

Merged
gengjiawen merged 3 commits into
tabrindle:mainfrom
mayankdhingra02:codex/parse-android-cli-sdk-packages
Nov 11, 2026
Merged

gengjiawen merged 3 commits into
tabrindle:mainfrom
mayankdhingra02:codex/parse-android-cli-sdk-packages

Conversation

@mayankdhingra02

Copy link
Copy Markdown
Contributor

Fixes #308.

Android command-line tools 23.0 use slash-separated package paths and colored, whitespace-separated rows. Read those installed rows alongside the legacy pipe-separated table so envinfo reports the SDK API levels, build tools, and system images again.

Added a regression for colored CRLF output, minor API levels, an available update, and the available-packages boundary. The full suite passed on Node 24 and 26. Replayed both SDK manager captures through the CLI and verified the old report still matches. The SDK 23.0 run used the reporter’s Windows capture. The native Windows job remains a hosted check.

mayankdhingra02 and others added 2 commits November 10, 2026 10:02
Split each row of `sdkmanager --list` into its package path and
description, from the `|`-separated table of the legacy sdkmanager or the
whitespace-separated rows of the Android CLI, and classify both alike.

- Strip every ANSI escape sequence, not only colors.
- List an API level once, so SDK extensions (android-35-ext14) no longer
  repeat it.
- Report minor API levels and preview build tools as listed in both
  formats (36.1, 36.0.0-rc1).
- Skip lines that are not package rows instead of throwing on them.
- Fall back to the tag and ABI of a system image without a description.

@gengjiawen gengjiawen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! I pushed 6a4f79f on top of this to address a few things found in review:

  • One row parser for both formats. Each row of sdkmanager --list is split into a package path and description (| columns for the legacy sdkmanager, whitespace for the Android CLI), and ; and / paths are classified the same way, so the two formats can no longer drift apart.
  • All ANSI escapes are stripped, not only SGR colors. Rows with a prefix such as ESC[2K or ESC(B were dropped before.
  • API levels are deduplicated. With the #308 list, platforms/android-35-ext14 and -ext15 reported 35 three times.
  • Minor API levels and preview build tools are reported as listed in both formats (36.1, 36.0.0-rc1). Before, the legacy path cut them to 36 and 36.0.0, so the same SDK gave a different report depending on the sdkmanager version.
  • Lines that are not package rows are skipped. The legacy path threw a TypeError on a line such as Warning: Observed package id 'system-images;…' in inconsistent location, which rejected the whole envinfo run.
  • A system image without a description falls back to its tag and ABI instead of becoming android-26 | or being dropped.
  • Tests cover rows from the #308 list (extension platforms, minor levels, cmake/ndk/sources rows), LF and uncolored rows, update arrows, other escapes, and the legacy edge cases above.

About the reproducer in #308: the gist's sdkmanager-cmdline-tools-23.txt stores each escape as the two printable characters ^[, not an ESC byte, so repro.sh still reports Not Found with any parser. After sed 's/\^\[/\x1b/g', envinfo reports API Levels 33, 35, 36, 37.0, 37.2, Build Tools 35.0.0, 36.0.0, 36.1.0, 37.0.0, and all 12 system images.

@gengjiawen
gengjiawen merged commit 3186b6e into tabrindle:main Nov 11, 2026
7 checks passed
@gengjiawen

Copy link
Copy Markdown
Collaborator

Merged, thanks for the fix @mayankdhingra02!

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.

Android SDK: Not Found with the command-line tools 23.0, whose sdkmanager lists build-tools/35.0.0 instead of build-tools;35.0.0

2 participants