Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

sdkmanager says it could not determine the SDK root

ErrorCould not determine SDK root.

Short answer

sdkmanager works out the SDK root from the folder it sits in. If you unzipped the command-line tools anywhere else, or left out the latest sub-folder, it cannot. Put the unzipped files in <sdk>/cmdline-tools/latest, or pass --sdk_root with the SDK path on every call.

  • Applies to Android SDK Command-line Tools latest, Flutter 3.3x stable, macOS, Linux, Windows
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find where sdkmanager really is, then look at the folders above it. The tool expects the path to end in cmdline-tools/latest/bin, inside the SDK folder.

    which sdkmanager
    ls "$ANDROID_HOME/cmdline-tools"
  2. 2Match what you see, then jump to its fix

    1. 1sdkmanager sits in cmdline-tools/bin, or in a folder outside any SDKThe zip was extracted without the cmdline-tools/latest layoutFix
    2. 2sdkmanager runs from a download folder or a copy elsewhereThe tool is outside the SDK and you did not say where the SDK isFix

What does the error look like?

  • Could not determine SDK root.

Cause 1 of 2

The zip was extracted without the cmdline-tools/latest layout

1Check

Android's guide says to move the unzipped cmdline-tools directory into your SDK directory, create a sub-directory called latest, and move the contents (bin, lib, NOTICE.txt, source.properties) into it.

ls -R "$ANDROID_HOME/cmdline-tools" | head -20

2Fix

Recreate the layout from the guide.

cd "$ANDROID_HOME/cmdline-tools"
mkdir latest
mv bin lib NOTICE.txt source.properties latest/

3Verify

Run the tool from its new path.

"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --list

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

The tool is outside the SDK and you did not say where the SDK is

1Check

The --sdk_root option makes the tool use the SDK path you give instead of the SDK containing the tool.

echo "$ANDROID_HOME"

2Fix

Pass the SDK path on the command line, and set ANDROID_HOME so other tools find the same folder.

sdkmanager --sdk_root="$HOME/Library/Android/sdk" --list
export ANDROID_HOME="$HOME/Library/Android/sdk"

3Verify

The package list prints with no error.

sdkmanager --sdk_root="$ANDROID_HOME" --list

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Set ANDROID_HOME in your shell profile.
  • Do not use ANDROID_SDK_ROOT; Android marks it deprecated.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

A phone is plugged in over USB but Android Studio and adb do not list it

adb devices prints List of devices attached with nothing below it

adb lists a phone only when four things hold: USB debugging is on, you accepted the computer's RSA key on the phone, the computer has a driver or udev rule for the device, and the cable carries data to a running adb server.

6 causes, each with a fix

Mobile apps

Flutter's Android build stops: JAVA_HOME is not set

ERROR: JAVA_HOME is set to an invalid directory

The Gradle wrapper script needs a Java runtime and looks in two places: the JAVA_HOME variable, then a java command on PATH.

3 causes, each with a fix

Mobile apps

flutter doctor cannot find the Android SDK

Unable to locate an Android SDK.

Flutter looks for the SDK in a fixed order: its own android-sdk setting, then ANDROID_HOME, then ANDROID_SDK_ROOT, then the default folder for your system.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.