Android Command line tools sdkmanager always shows: Warning: Could not create settings

Instead of passing the argument --sdk_root for each single command execution, let's deep dive into the real cause.

Starting from Android SDK Command-line Tools 1.0.0 (6200805), in contrast to Android SDK 26.1.1 (4333796), the tools directory hierarchy has been changed. Previously it was placed right inside ANDROID_HOME (which is deprecated, we will use the term ANDROID_SDK_ROOT for the rest of the paragraph), now it's still named as tools (the only thing you'll get after unpacking the downloaded commandlinetools zip file), but differently, you have to place it inside a directory called cmdline-tools on your own. The name cmdline-tools comes from its package name, where you can get from listing packages command sdkmanager --list, whose outputs include cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools.

Wrapping tools directory inside cmdline-tools directory would make it work, and help you get rid of the annoying --sdk_root argument. But what about the other parts?

Well, that's all you have to change. Let me explain more.

  • The king - sdkmanager lives inside cmdline-tools/tools/bin, you'd better set in PATH environment variable
  • cmdline-tools should not be set as ANDROID_SDK_ROOT. Because later, when updating Android SDK, or installing more packages, the other packages will be placed under ANDROID_SDK_ROOT, but not under cmdline-tools.
  • The final, complete ANDROID_SDK_ROOT directory structure should look like below, consist of quite a few sub-directories: build-tools, cmdline-tools, emulator, licenses, patcher, platform-tools, platforms, system-images. You can easily point out that build-tools and cmdline-tools are siblings, all sit inside the parent ANDROID_SDK_ROOT.

Let me recap in a simple way:

  • Set your preferred ANDROID_SDK_ROOT (just like before)
  • Download and unpack the commandlinetools zip file into a directory called cmdline-tools, which is inside ANDROID_SDK_ROOT
  • Append the directory $ANDROID_SDK_ROOT/cmdline-tools/tools/bin to environment variable PATH, so that the system knows where to find sdkmanager

!!UPDATE!!

The behavior has changed again since the build 6858069 (Android SDK Command-line Tools 3.0):

  • After unzipping the package, the top-most directory you'll get is cmdline-tools.
  • Rename the unpacked directory from cmdline-tools to tools, and place it under $ANDROID_SDK_ROOT/cmdline-tools, so now it should look like: $ANDROID_SDK_ROOT/cmdline-tools/tools. And inside it, you should have: NOTICE.txt bin lib source.properties. Actually according to the official Command-Line Tools doc, the tree structure should be android_sdk/cmdline-tools/version/bin/, but I've checked, using version or tools makes no difference here.
  • For your environment variable PATH, I would recommend you to set like this: PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin, because after update later, you'll get the latest sdkmanager placed under $ANDROID_SDK_ROOT/cmdline-tools/latest/bin, put it in front will make it higher priority.

This appears to be a bug with the way sdkmanager locates the SDK installation folder.

A work-around is to set the flag --sdk_root. You can move ANDROID_HOME declaration higher, then use it with the subsequent commands.

 - export ANDROID_HOME=$PWD/android-sdk-linux
 - yes | android-sdk-linux/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
 - android-sdk-linux/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null

Also, moved blanket license acceptance command to the first command to clean up the echo y parts.

Oddly enough if you run sdkmanager --sdk_root=${ANDROID_HOME} "tools" it will upgrade tools from 3.6.0 to 26.1.1 and sdkmanager no longer has this issue. This update takes time and bandwidth and isn't exactly necessary with the work-around.


For those who struggled with installing Android Command Line Tools for Appium on Windows 10/x64 just do as following:

  1. Download latest Command line tools from android i.e. commandlinetools-win-6200805_latest.zip
  2. Unzip the downloaded file
  3. Create directory for storing commandline tools somewhere on your disk, with following path included: android/cmdline-tools/latest Basically when You unzip this Cmd line tools, just rename tools directory to latest and make sure You put this latest folder in android/cmdline-tools directory somewhere on your disk
  4. Create ANDROID_HOME environment variable for directory that stores the cmdline tools directory location like: C:\YourLocationWhereYouStoreTheDirectory\android\cmdline-tools\latest
  5. Create new entry in Path environment variable as %ANDROID_HOME%\bin