Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

## [1.0.2] - Unreleased

- Also export `ANDROID_SDK_ROOT` for compatibility with newer Gradle plugins
that read it directly.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ steps:
| 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`. |
| `sdk-path` | platform default | Override SDK install location. Exported as both `ANDROID_HOME` and `ANDROID_SDK_ROOT`. |
| `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. |
Expand All @@ -87,11 +87,20 @@ steps:
| `cli-version` | Version string from `android --version`. |
| `cache-hit` | Whether the cache was restored (`true`/`false`, empty if caching disabled). |

## Environment

The action exports the following environment variables for subsequent steps:

| Variable | Description |
|---|---|
| `ANDROID_HOME` | Absolute path to the SDK. Set for back-compat with older tooling. |
| `ANDROID_SDK_ROOT` | Same value as `ANDROID_HOME`. Set because newer Android tooling (AGP 8.x, recent Gradle plugins, the cmdline-tools `sdkmanager`) reads this variable first and only falls back to `ANDROID_HOME` when it is unset. |

## What it does

1. Downloads the `android` CLI launcher (~5 MB) into the runner's tool cache.
2. Unpacks embedded resources on first run into `~/.android/bin/` (~78 MB, cached).
3. Exports `ANDROID_HOME` and adds `platform-tools/`, `emulator/`, and `cmdline-tools/latest/bin/` to `PATH`.
3. Exports `ANDROID_HOME` and `ANDROID_SDK_ROOT`, and adds `platform-tools/`, `emulator/`, and `cmdline-tools/latest/bin/` to `PATH`.
4. Runs `android sdk install <packages>` if packages are specified.
5. Registers Gradle, Kotlin, and Android Lint [problem matchers](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) so build errors show inline in the GitHub UI.
6. Writes a job summary table with CLI version, SDK path, and cache status.
Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ inputs:
description: >-
Override where the Android SDK is installed. Defaults to
`~/Library/Android/sdk` on macOS and `~/Android/Sdk` on Linux. The
chosen path is exported as `ANDROID_HOME` for subsequent steps.
chosen path is exported as `ANDROID_HOME` and `ANDROID_SDK_ROOT` for
subsequent steps.
required: false
default: ''
cache:
Expand Down Expand Up @@ -149,13 +150,14 @@ runs:
ANDROID_CLI_FRESH_INSTALL=1 android --version
echo "::endgroup::"

- name: Configure ANDROID_HOME
- name: Configure ANDROID_HOME and ANDROID_SDK_ROOT
shell: bash
env:
SDK_PATH: ${{ steps.platform.outputs.sdk-path }}
run: |
set -euo pipefail
echo "ANDROID_HOME=$SDK_PATH" >> "$GITHUB_ENV"
echo "ANDROID_SDK_ROOT=$SDK_PATH" >> "$GITHUB_ENV"
# Also export common adjacent PATH entries so later steps can call
# adb / emulator without setting PATH themselves. These are only
# populated once their packages are installed.
Expand Down