fix(cli): Android SDK auto-installation failing on Windows - #6892
Open
ndonkoHenri wants to merge 3 commits into
Open
ndonkoHenri wants to merge 3 commits into
ndonkoHenri wants to merge 3 commits into
Conversation
On Windows the installer answered the license prompts with `cmd.exe /C echo y | sdkmanager.bat ...`. The space before the pipe is part of what cmd's `echo` prints, so sdkmanager read "y " and declined every license, which skipped each package. sdkmanager exits with 0 when it skips a package or when licenses are declined, so the installer reported the SDK as installed and Flutter later failed with "No Android SDK found". A single answer could not have accepted the licenses anyway: `--licenses` asks once before the licenses and once per license. sdkmanager now runs directly on every platform, with its answers written to its standard input, and the installer fails when a package directory or the SDK license file is missing after sdkmanager returns.
Version 23.0 of the Android SDK command-line tools replaces sdkmanager with a wrapper around the Android CLI. The wrapper downloads the Android CLI on first use and ignores `--licenses`. It also rejects `--no-metrics`, so the Android CLI collects usage metrics by default. On Windows, the wrapper splits package names such as `platforms;android-35` at the `;`. On Windows 11 ARM64, where the x64 `android.exe` runs emulated, every Android CLI run exits with 0xC0000409, even after installing the package. Installing `cmdline-tools;latest` brought that version into every new SDK and made it the sdkmanager used for the remaining packages. Flutter only needs a `cmdline-tools` directory, so the pinned version that the installer downloads is enough. `cmdline-tools;latest` is no longer installed, and the pinned version is preferred over `latest` when both are present.
Deploying flet-website-v2 with
|
| Latest commit: |
bec12f4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a3cadfda.flet-website-v2.pages.dev |
| Branch Preview URL: | https://fix-windows-android-sdk-lice.flet-website-v2.pages.dev |
ndonkoHenri
requested review from
FeodorFitsner
and
a balanced review from Copilot
September 26, 2026 01:08
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The implementation appears sound, but GitHub currently reports unresolved merge conflicts.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes Android SDK auto-installation by reliably accepting licenses and validating installed packages.
Changes:
- Sends SDK manager responses through standard input.
- Prefers pinned command-line tools 12.0 and verifies installation results.
- Adds the 1.0.2 changelog entry.
| File | Description |
|---|---|
processes.py |
Adds subprocess input support. |
android_sdk.py |
Fixes SDK package and license installation. |
CHANGELOG.md |
Documents the Windows fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6522
Problem
On a Windows machine without an Android SDK,
flet build apkdid not install the SDK: it downloaded the command-line tools, declined every SDK license, installed none of the packages, and still reportedAndroid SDK installed ✅. Flutter then failed withNo Android SDK found.The installer answered the license prompts with
cmd.exe /C echo y | sdkmanager.bat …. The space before the pipe is part of what cmd'sechoprints, so sdkmanager read"y "and treated it as "no". sdkmanager exits with 0 when it skips a package or when licenses are declined, and the installer only checked the exit code. A single answer could not have accepted the licenses anyway:--licensesasks once before showing them and then once per license.Fixing that exposed a second problem, which affects every OS.
cmdline-tools;latestnow resolves to version 23.0 of the command-line tools, which replacessdkmanagerwith a wrapper around Google's new Android CLI. The installer installedcmdline-tools;latestfirst and then used itssdkmanagerfor the remaining packages. The wrapper:~/.androidon first use;--licenses;--no-metrics, so the Android CLI collects usage metrics by default;platforms;android-35at the;, because cmd treats;as an argument separator, so those packages are never found;android.exeruns emulated, exits with0xC0000409on every run, even when the package was installed. x64 Windows is untested.Changes
sdkmanagerruns directly on every OS, with its answers written to its standard input. This replaces thecmd.exe /C echo y |andsh -c 'yes | …'pipelines.processes.run()gets aninputparameter for this.licenses/android-sdk-licenseis missing aftersdkmanagerreturns, instead of trusting the exit code.cmdline-tools;latestis no longer installed, and the pinned command-line tools (12.0) that the installer downloads are preferred overlatestwhen both are present. Flutter only needs acmdline-toolsdirectory, of any version.Not in this PR: an SDK whose only command-line tools are 23.0, for example Android Studio's "Command-line Tools (latest)", still goes through the wrapper when a package is missing, as on 1.0.1. Installing the pinned tools in that case, without prompting users whose SDK is already complete, needs a separate change to
install().Testing
AndroidSDK.install(), which is whatflet build apkruns when no SDK is found:b'y \r\n', and only the downloaded command-line tools ended up on disk, with no licenses accepted, yetinstall()returned normally.platform-tools,platforms;android-35andbuild-tools;34.0.0and accepted all 7 licenses, with everysdkmanagercall going through the pinned 12.0 tools. It also completed an SDK that already had 23.0 aslatest.sdkmanager.batandandroid.exedirectly on the same VM confirmed the;splitting and the0xC0000409exit codes.sdkmanagerin throwaway SDK folders: an install into an empty folder passes, and feeding the same"y "answer makes the installer raiseError installing Android SDK package "platform-tools"instead of returning.Test code
Summary by Sourcery
Fix Android SDK installation reliability across platforms by using the pinned SDK tools, accepting licenses through standard input, and validating installation results.
Bug Fixes:
Enhancements: