dotnet / dotnet/android

Add SDK license acceptance support (move from android-platform-support)

Open
#12,067 1 comment 0 reactions 0 assignees View on GitHub
android-tools enhancement needs-triage
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

## Summary

Add SDK license acceptance support to `Xamarin.Android.Tools.AndroidSdk` for unattended/CI scenarios across all .NET Android tooling.

## Background

The `android-platform-support` (internal) repository has `AndroidLicensesStorage` with battle-tested license acceptance that:
- Orchestrates `sdkmanager --licenses` as a subprocess
- Handles interactive Y/N prompts and sends acceptance answers
- Writes license hashes to `\/licenses/` directory
- Supports both Google and VS license formats
- Handles platform differences (`sdkmanager.bat` on Windows vs `sdkmanager` on macOS/Linux)
- Validates that Android SDK, Java SDK, and cmdline-tools paths exist before proceeding

This capability should be moved to the public `Xamarin.Android.Tools.AndroidSdk` package.

## Proposed API Surface

- `LicenseManager.AcceptAllAsync(sdkPath)` — accept all pending SDK licenses via `sdkmanager --licenses`
- `LicenseManager.IsAccepted(sdkPath, licenseId)` — check if a specific license is accepted
- `LicenseManager.GetPendingAsync(sdkPath)` — list licenses that need acceptance

## Consumer

- **MAUI DevTools CLI** (`maui android sdk accept-licenses`, `maui android install --accept-licenses`) — see [MAUI DevTools Spec PR](https://github.com/dotnet/maui/pull/33865)
- **CI/CD pipelines** — unattended builds that need to accept licenses without user interaction

## Related

- MAUI DevTools spec §6.8: Shared Libraries & Code Reuse

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.