-
Notifications
You must be signed in to change notification settings - Fork 79
android_sdk_repository: Support string-based platform API levels (e.g., "36.1") #472
Description
Summary
The android_sdk_repository rule currently assumes API levels are integers. With the introduction of minor version API levels (e.g., 36.1), the rule fails to correctly parse, compare, and reference these levels, breaking SDK setup for newer Android platform releases.
Problem Description
Android SDK platform directories may now use minor version identifiers (e.g., platforms/android-36.1/). The existing implementation:
- Defines api_level as an integer-typed config flag (int_flag)
- Uses %d string formatting for API level references (names, paths, log messages)
- Selects the default API level via integer comparison
This means any SDK that ships a platform with a minor version (e.g., 36.1) will either be silently ignored or cause a type error, preventing users from building against the latest Android SDK releases.
Expected Behavior
android_sdk_repository should:
- Accept API level values in both integer (36) and dot-separated string (36.1) formats.
- Correctly identify the latest/default API level across integer and minor-version entries.
- Generate valid Bazel target names and file paths using the string representation (e.g., sdk-36.1).
Actual Behavior
Minor-version API levels are not recognized. The rule either skips platforms with minor versions or produces incorrect Bazel targets/paths because it attempts to parse "36.1" as an integer.
Reproduction Steps
- Only Install an Android SDK that includes a platforms/android-36.1/ directory.
- Configure android_sdk_repository in your WORKSPACE (or MODULE.bazel).
- Run any Bazel build targeting @androidsdk//:android or relying on the auto-selected default API level.
- Observe that the target does not exist or an error is raised.
Proposed Fix
Migrate API level handling from int to string throughout android_sdk_repository:
- Replace int_flag with string_flag for the api_level config setting.
- Use is_android_revision to validate platform directory names.
- Compare API levels by parsing major/minor/micro components to determine the default.
- Update all format strings from %d to %s.