Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

How do I fix Android Sdkmanager not found?

To Solve Android sdkmanager tool not found in Flutter The right solution would be if you have android studio installed then the command flutter doctor and it should now prompt you to run flutter doctor –android-licenses, once you run the license command, accept all licenses by hitting Y and it should solve the problem.

How use Sdkmanager command-line?

To use the SDK Manager to install a version of the command line tools, follow these steps: Download the latest "command line tools only" package from the Android Studio downloads page and unzip the package. Move the unzipped cmdline-tools directory into a new directory of your choice, such as android_sdk .

How do I run Sdkmanager?

You can launch the SDK Manager in one of the following ways: From Eclipse (with ADT), select Window > Android SDK Manager. On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory.


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

The sdkmanager tries to figure out the android-sdk path based in where it's unpacked, without use the environment variables, like ANDROID_SDK_ROOT. But it's get worse, because it have a hard coded parent folder named cmdline-tools and if you unzip commandlinetools inside a folder with another name, it doesn't work, forcing us to use the parameter sdk_root to feed the inside variable correctly.

So, with that in mind we can use the following approach to solve this.

I will assume that we are using Ubuntu OS, so if you aren't, you should adapt some of that instructions.

  1. Install Android-SDK.

     sudo apt install android-sdk
    

    After the instalation you will have a folder called android-sdk in /usr/lib

  2. Create a folder called cdmline-tools inside the android-sdk folder

     sudo mkdir /usr/lib/android-sdk/cmdline-tools
    
  3. Download the Android command line tools zip from here (https://developer.android.com/studio?hl=en-419#downloads)

  4. Unpack the file you just downloaded inside /usr/lib/android-sdk/cmdline-tools

     sudo unzip /path/for/commandlinetools-linux-6200805_latest.zip -d /usr/lib/android-sdk/cmdline-tools
    
  5. Go to you home dir and edit your .profile

     nano .profile
    
  6. Create an ANDROID_SDK_ROOT variable

     export ANDROID_SDK_ROOT=/usr/lib/android-sdk
    
  7. Put the sdkmanager folder in your path

     export PATH=$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$PATH
    
  8. Save and Exit

  9. Reload you profile

     . ~/.profile
    
  10. Run

    sdkmanager --version
    

You should see the version printed in your terminal.


Downloading the new cmdline-tools from Android Developer website requires the following directory structure to be respected.