Android SDK, Licenses, and ADB: Debug the Failure Chain in Order
Android setup errors are often connected. Check the SDK path, command-line tools, licenses, and ADB state in order instead of reinstalling everything.
Why the order matters
An Android project can fail before it reaches your application code. If sdkmanager is missing, licenses cannot be accepted. If the SDK path points to a different directory, a license accepted in one installation does not help the toolchain using another. If ADB is stale or the device is unauthorized, a successful build still cannot install the app.
Treat setup as four separate checks.
1. Confirm the selected SDK
Print the variables and locate the command that is actually being used:
printf 'ANDROID_HOME=%s\n' "$ANDROID_HOME"
printf 'ANDROID_SDK_ROOT=%s\n' "$ANDROID_SDK_ROOT"
command -v sdkmanager || true
command -v adb || trueOn macOS, the common SDK directory is $HOME/Library/Android/sdk, but do not copy that path blindly from another account. Run sdkmanager --list and confirm that the output belongs to the SDK you expect.
2. Install command-line tools into the expected layout
The executable should be reachable as cmdline-tools/latest/bin/sdkmanager or through an equivalent configured path. The exact folder name matters to some Flutter and Android tooling. Check the directory structure before adding more exports to shell startup files.
Install the platform tools, the platform version your project targets, and the build tools version it requests. Keep those versions visible in the project documentation rather than relying on whatever Android Studio last downloaded.
3. Accept licenses against that SDK
Run:
flutter doctor --android-licenses
flutter doctor -vIf the command says the license status is unknown, first suspect a path or command-line-tools problem. Accepting prompts repeatedly will not repair a tool that is reading another SDK directory.
4. Reset and inspect ADB
adb kill-server
adb start-server
adb devices -lAn unauthorized device needs confirmation on the device. An offline device needs a connection or emulator reset. An empty list means the transport is not visible; it does not indicate an application build failure.
The Android SDK Command Builder generates a reviewable command set for shell or PowerShell. It does not download packages or accept licenses automatically in your environment.