Setup Android CLI
ActionsTags
(2)A GitHub Action that installs Google's agent-first android CLI, sets up the Android SDK, and caches between runs. Drop-in replacement for setup-android with a simpler, faster setup.
setup-android |
setup-android-cli |
|
|---|---|---|
| Download size | ~300 MB (cmdline-tools zip) | ~5 MB (single binary) |
| Install | Unzip + accept licenses + sdkmanager | curl one binary |
| Package syntax | "platforms;android-34" (semicolons) |
platforms/android-34 (slashes) |
| License prompt | yes | sdkmanager --licenses |
Auto-accepted, non-interactive |
| Action type | JavaScript (Node 20, bundled) | Composite (pure YAML + shell) |
| Version tracking | Pin a cmdline-tools build number | Always installs the current CLI release |
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: premex-ab/setup-android-cli@v1
with:
packages: platform-tools
- run: ./gradlew --no-daemon build - uses: premex-ab/setup-android-cli@v1
with:
packages: |
platforms/android-34
build-tools/34.0.0
platform-tools - uses: premex-ab/setup-android-cli@v1
- run: android --version - uses: premex-ab/setup-android-cli@v1
with:
sdk-path: /opt/android-sdk
packages: platforms/android-34 build-tools/34.0.0 platform-tools - uses: premex-ab/setup-android-cli@v1
with:
cache: 'false'
packages: platform-tools| Input | Default | Description |
|---|---|---|
packages |
'' |
SDK packages to install, space- or newline-separated (slash syntax). Empty = CLI only. |
sdk-path |
platform default | Override SDK install location. Exported as ANDROID_HOME. |
cache |
'true' |
Cache ~/.android/bin and the SDK between runs. |
cache-key |
'' |
Extra input appended to cache key (for busting). |
no-metrics |
'true' |
Pass --no-metrics to opt out of CLI telemetry. |
install-url-base |
Google redirector | Override download URL base (for mirrors / air-gap). |
| Output | Description |
|---|---|
sdk-path |
Absolute path to the installed Android SDK. |
cli-version |
Version string from android --version. |
cache-hit |
Whether the cache was restored (true/false, empty if caching disabled). |
- Downloads the
androidCLI launcher (~5 MB) into the runner's tool cache. - Unpacks embedded resources on first run into
~/.android/bin/(~78 MB, cached). - Exports
ANDROID_HOMEand addsplatform-tools/,emulator/, andcmdline-tools/latest/bin/toPATH. - Runs
android sdk install <packages>if packages are specified. - Registers Gradle, Kotlin, and Android Lint problem matchers so build errors show inline in the GitHub UI.
- Writes a job summary table with CLI version, SDK path, and cache status.
| Runner | Status |
|---|---|
ubuntu-latest / ubuntu-22.04 |
Supported |
macos-latest / macos-14 (Apple Silicon) |
Supported |
macos-13 (Intel, Rosetta) |
Best-effort (warning emitted) |
windows-* |
Not yet supported (the CLI itself has limited Windows support) |
| Self-hosted Linux x86_64 / macOS arm64 | Supported |
By default the action caches ~/.android/bin (CLI resources, ~78 MB) and the full SDK directory between runs. The cache key includes OS, architecture, and the hash of **/libs.versions.toml, **/build.gradle*, and **/settings.gradle* so it busts when your project's SDK requirements change.
Gradle caching is not handled by this action. Use gradle/actions/setup-gradle@v4 for that.
- name: Setup Android SDK
- uses: android-actions/setup-android@v3
- with:
- packages: 'tools platform-tools'
+ uses: premex-ab/setup-android-cli@v1
+ with:
+ packages: platform-toolsKey differences:
- No
cmdline-tools-versioninput (always current release). - No
accept-android-sdk-licensesinput (auto-accepted). - Package names use slashes instead of semicolons:
platforms/android-34not"platforms;android-34". toolspackage doesn't exist in the new CLI; drop it.
This action registers problem matchers for:
- Android Lint warnings and errors
- Gradle build errors
- Kotlin compiler warnings and errors
These surface build issues as inline annotations in the GitHub UI.
Setup Android CLI is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.