sdkmanager says it could not determine the SDK root
Could 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.
Fix it fast
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"2Match what you see, then jump to its fix
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 -202Fix
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" --listConfirmed by developer.android.com
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" --listConfirmed by developer.android.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
flutter doctor says the Android cmdline-tools component is missing
Android license status unknown.
Flutter checks for a cmdline-tools folder inside the Android SDK it found, and stops the Android checks when that folder is absent.
6 causes, each with a fixMobile 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 fixMobile 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 fixMobile apps
flutter run hangs for minutes on Running Gradle task 'assembleDebug'
Downloading https://services.gradle.org/distributions/gradle-8.14-all.zip
That line only says Gradle started; the wait is inside Gradle.
3 causes, each with a fixMobile apps
flutter doctor cannot find the Java that comes with Android Studio
Unable to find bundled Java version.
Flutter looks for the Java inside Android Studio first, then JAVA_HOME, then any java on PATH.
3 causes, each with a fixMobile 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