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

24

218

I use the new command line tools for Android because the old sdk-tools repository of Android isn't available anymore. So I changed my gitlab-ci to load the commandlintools. But when I try to run it I get the following error:

Warning: Could not create settings
java.lang.IllegalArgumentException
    at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

I already tried executing those commandy by hand, but I get the same error. Also if I run sdkmanager --version, the same error occurs. My gitlab-ci looks like:

image: openjdk:9-jdk

variables:
  ANDROID_COMPILE_SDK: "29"
  ANDROID_BUILD_TOOLS: "29.0.3"
  ANDROID_SDK_TOOLS:   "6200805"

before_script:
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  #- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export ANDROID_HOME=$PWD/android-sdk-linux
  - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
  - chmod +x ./gradlew
  # temporarily disable checking for EPIPE error and use yes to accept all licenses
  - set +o pipefail
  - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
  - set -o pipefail

stages:
  - build
  - test

lintDebug:
  stage: build
  script:
    - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint

assembleDebug:
  stage: build
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
    - app/build/outputs/

debugTests:
  stage: test
  script:
    - ./gradlew -Pci --console=plain :app:testDebug
Digastric answered 27/2, 2020 at 19:32 Comment(0)
E
458

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.
Encampment answered 12/4, 2020 at 19:6 Comment(23)
This is the correct answer. Unlike the other answers this keeps the "tools" directory, which is actually what is in the zip file.Cosher
Thank you so much, you have answered my question :)Bonded
I followed the instructions here - very helpful - thanks! However, I noticed that after running "sdkmanager --install "build-tools;29.0.3", another "tools" folder was created inside $ANDROID_HOME, besides the already existing "$ANDROID_HOME/cmdline-tools/tools". That folder seem to have a few more binaries, so looks like should be the one to be added to the PATH. Did you face this? Using sdkmanager v3.6.0 - downloaded today.Expectorate
ANDROID_HOME is deprecated. we should be migrating to ANDROID_SDK_ROOT. source: developer.android.com/studio/command-line/variables#envarOracular
At the time of writing, there are 3 different sdkmanager binaries after updating. $ANDROID_SDK_ROOT/tools/bin/sdkmanager --version => 26.1.1 $ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager --version => 3.6.0 $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --version => 4.0.0Encampment
Thanks. Renaming the tools parent dir to cmdline-tools fixed it for me. Can't believe how brittle the Android SDK is howeverUnderachieve
I'm quite sure it's intentional - Google wants to make the process as difficult as possible to try to migrate everyone to the huge studio package. It's great that we have Stack Overflow to solve these annoyances.Selfcontradiction
I just put the downloaded tools folder in cmdline-tools and then renamed it to latest like $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager... And after running sdkmanager, I don't see other unnecessary folders created as described by @JingLi in his comment above like $ANDROID_SDK_ROOT/tools/bin/... , $ANDROID_SDK_ROOT/cmdline-tools/tools/bin/..., and everything works perfectly. Ubuntu 20.04. Thanks.Laughry
It worked for me but now I have a warning "Observed package id 'tools' in inconsistent location '/home/{username}/.android/sdk/cmdline-tools/tools' (Expected '/home/{username}/.android/sdk/tools')"They
@PaulLaffitte that's weird. Because the /tools path is the old one, the new one should be /cmdline-tools/tools. Could you please try an update of your AndroidSDK, maybe the warning will go away as it should have the latest /cmdline-tools/tools.Encampment
Guys when using this answer consider that there is tools folder in cmdline-tools folder I tried three times before noticing it (and girls)Neoplasty
@PaulLaffitte, the location should be /home/{username}/.android/sdk/cmdline-tools/latestConscript
Has this changed recently? Within the commandlinetools-win-6858069_latest.zip (as well as the linux version) archive I downloaded, sdkmanager is located at cmdline-tools\bin\sdkmanager. Is it necessary to add a latest or tools folder?Gironde
Okay, after moving the contents of cmdline-tools under cmdline-tools\latest, sdkmanager appears to be working.Gironde
@ChristianReall-Fluharty yes, the behavior of the most recent package 6858069 is changed, I'm working on an update. But TBH, Google should rather fix it and make the behavior consistent and predictable, instead of we always guess and adapt.Encampment
After a tools update, the latest version has just got put in my <android_sdk_root>\tools\bin, so the above path may need updating? (This tool is /so/ fragile)Hagiocracy
Yes @Ian, it's changing when you update it. And the behavior is different, that's why I can't give any certain path here. It's also mentioned here: github.com/thyrlian/AndroidSDK/issues/36Encampment
This has changed again. Every release google changes the structure. See this answer for the latest: https://mcmap.net/q/66972/-cmdline-tools-could-not-determine-sdk-rootHemingway
@MattWolfe please read patiently inside the !!UPDATE!! section, it's mentioned that: The behavior has changed again since the build 6858069, after unzipping the package, the top-most directory you'll get is cmdline-tools. It's not like you've said: For "commandlinetools-linux-7302050_latest.zip" the process was different from earlier approaches. Earlier after unpacking, the top folder was called tools, but now the top folder is called cmdline-tools.Encampment
@JingLi But the structure below cmdline-tools base folder changed between those two releases, but yeah they both had top level comdline-tools. I had to update my CI script again with the 7xxx release. Every update they've done in the last 3 or 4 releases has required CI changes for me.Hemingway
@MattWolfe, I just downloaded two versions: 6858069 & 7302050, and had a careful look. The tree structures don't vary between them. 7302050 has added a new binary retrace under bin directory. Some tool's version update under lib/external. A few new libraries have been added into lib/external: javax.inject, jna, xerces, xml-apis. That's all, no fundamental change in terms of structure-wise. Please see the raw output and comparison here: gist.github.com/thyrlian/1cf9ec816cbb28a020b6fe4f29168677Encampment
Now apparently ANDROID_SDK_ROOT is deprecated: "ANDROID_SDK_ROOT, which also points to the SDK installation directory, is deprecated." developer.android.com/tools/variables#envarGuarantee
@SaadFarooq yes it's very confusing. I suppose the easiest answer is to set bothHolladay
G
117

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.

Guardant answered 28/2, 2020 at 14:56 Comment(8)
worked fine, now I get an error with ./gradlew assembleDebug, but it seems that this has nothing to do with the sdkmanager anymore. Thank you!Digastric
Can you please give me an example how I can clean up my echo y? I don't get it.Digastric
I've updated the snippet in my original response to clarify removing the echo y commands.Guardant
Thank you! Helps a lot!Digastric
the export line and then the sdkmanager --sdk_root=${ANDROID_HOME} "tools" bit did it for me -- thanks!Dutybound
The - in the start of the statement are misleading.Cyanocobalamin
Doing sdkmanager --sdk_root=${ANDROID_HOME} "tools" leads to errors for me reporting that "tools" folder is already used (as it contains sdkmanager itself maybe). ArturS answer, proposing to store sdkmanager in cmdline-tools/latest makes everything work perfectly.Level
~I needed to add yes | android-sdk-linux/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses || true because the command kept being detected as failed by gitlab-ci~. Sorry, missed +o pipefailCamelopardalis
C
43

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
Chilly answered 9/3, 2020 at 10:44 Comment(6)
Where does the need of this "android/cmdline-tools/latest" comes from ? source code ? some doc somewhere ?Shit
The reason is described under this topic: #60460929Chilly
In the topic you are referencing, the answer says "export ANDROID_HOME="/Users/darish/development/sdk/android"" no "latest", no "cmdline-tools"Shit
@Shit cmdline-tools is a must have, however latest is not required. And the path (or name) of cmdline-tools comes from Android SDK itself. You can run this command sdkmanager --sdk_root=${ANDROID_HOME} --list, where the results includes "cmdline-tools;1.0 | 1.0 | Android SDK Command-line Tools"Encampment
I don't know what logic behind this. But it works :-)Prochoras
Perfect, it worked for me too. Just be very careful with the naming of the folders and it should work just fine.Scarlettscarp
D
32

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.

Dragonet answered 11/4, 2020 at 0:59 Comment(7)
it worked like a charm! thanks again for this complete solutionWindowshop
I still have the error of "Error: Could not find or load main class java.se.ee"- Could you explain why? And what should I do to solve this? You dint'd mentioned anything about that. CheersThenna
I did not experience this problem, but maybe that answer can help you. try itDragonet
foolder order and names ... very important!Thriller
I get android-sdk : Depends: android-sdk-platform-tools (>= 20) but it is not going to be installed and this has a dependency chain that don't automatically get resolvedMellicent
Followed every step. Worked without any issues. Thanks!Offenseless
worked like charm. for any one who has issues with package updates .. Warning: Failed to read or create install properties file. check this out [askubuntu.com/questions/1227439/…Nubia
D
27

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

Detect answered 28/2, 2020 at 23:45 Comment(3)
Why is it required ? where does this come from ? source code ? doc ?Shit
I setup my CI to use this structure and while it does allow me to run sdkmanager, when my project gets built with gradle it doesn't know how to locate platforms and licenses properly and everything fails.Hemingway
@MattWolfe, this happens because some tools only recognize the old SDK Tools (now deprecated)Detect
J
24

Simple Solution:

  1. Open Android Studio Tools Menu,
  2. SDK Manager In the window that comes up there are inner panels,
  3. Choose SDK Tools panel Tick Android SDK Command-line Tools
  4. Choose Apply button near the bottom of the window
Jugal answered 17/8, 2021 at 18:14 Comment(3)
Best solution on this pageHither
Short and precise!Thrift
This worked for me and saved much time!Selry
C
8

Mixing responses from Jing Li and caller9, this is my script:

variables:
  ANDROID_COMPILE_SDK: "29"
  ANDROID_BUILD_TOOLS: "29.0.3"
  ANDROID_SDK_TOOLS: "6200805"

before_script:
  - apt-get update --yes
  - apt-get install --yes wget tar unzip lib32stdc++6 lib32z1
  - export ANDROID_HOME=${PWD}android-home
  - install -d $ANDROID_HOME
  - wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
  - pushd $ANDROID_HOME
  - unzip -d cmdline-tools cmdline-tools.zip
  - popd
  - export PATH=$PATH:${ANDROID_HOME}/cmdline-tools/tools/bin/
  - sdkmanager --version
  - set +o pipefail
  - yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses
  - set -o pipefail
  - sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}"
  - sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
  - sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${ANDROID_BUILD_TOOLS}"
  - export PATH=$PATH:${ANDROID_HOME}/platform-tools/
  - chmod +x ./gradlew
[...]
Camelopardalis answered 16/5, 2020 at 15:12 Comment(0)
C
6

I found the solution to use the latest command-line tools following those steps:

1 - Extracting the Command-line tools into a folder with this structure: e.g.: $HOME/Development/android/cmdline-tools/latest (this folder must contain lib, bin, notice.txt and source.properties)

2 - Defining ANDROID_HOME as an environment variable:

ANDROID_HOME="$HOME/Development/android/cmdline-tools/latest"

3 - Loading it on PATH:

PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/lib:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools"
Copartner answered 2/3, 2020 at 19:31 Comment(3)
Contradictory informations : "latest (this folder must contain lib, bin, ...)", ANDROID_HOME=".../latest" PATH="...$ANDROID_HOME/tools/libShit
lib is in tools or in ANDROID_HOME ?Shit
cmdline-tools is a must have, however latest is not required.Encampment
J
6

I got the same error. After doing all solutions, i could not fix it. I solved this problem by reading: https://forum.unity.com/threads/android-build-not-working.844969/

Simplify an answer:

  1. Opening sdkmanager.bat by notepad++

  2. Changing this line from

    "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%  -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS%
    

    to

    "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%  -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS% --sdk_root=%ANDROID_HOME%
    

(Note: Adding --sdk_root=%ANDROID_HOME% at the end

Jurisconsult answered 5/5, 2020 at 13:10 Comment(1)
Thank you, easy and it works! :) But now you should use --sdk_root=%ANDROID_SDK_ROOT% instead.Theatricalize
R
5

Got the same issue, came here by Google. According to the AndroidStudio Archive, today was the release of 4.1. I suppose that's no coincidence.

This completely unrelated guide has a hardlink for an older version of the sdk-tools for linux. You can change the url to windows or mac for other OSs. I'll use that as a hotfix for now.

(that was supposed to be a comment not a solution)

Relaxation answered 27/2, 2020 at 21:15 Comment(1)
Links not working, I already tried using an old version, but I use new features in my code base so I can't use the old one anymore. So this solution don't work for me.Digastric
R
5

Summarizing several useful posts here, and for people wanting a quick snippet, for example to plug in a Dockerfile, the following script is working for me:

RUN mkdir -p /opt/android/cmdline-tools/latest \
    && cd /opt/android/cmdline-tools/latest \
    && wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip \
    && bsdtar --strip-components=1 -xvf commandlinetools-linux-6858069_latest.zip \
    && yes | bin/sdkmanager --licenses \
    && bin/sdkmanager "build-tools;29.0.2" "platforms;android-29" \
    && rm commandlinetools-linux-6858069_latest.zip

It just requires bsdtar to be installed (it's usually packaged in popular distributions). Android platform/build tools version 29 are installed, and Android sdk root will be then located in /opt/android. While this setup works for me without warnings as it is, I have an issue when reinstalling packages already installed, or possibly installing different version of the packages: it clashes with packages already present and create bogus directories in the sdk root, with -2, -3 suffixes. These directories are then ignored, and warnings like Observed package id 'emulator' in inconsistent location are printed, so this behavior is definitely not desirable. If you have a fix for that please write it in the comments or, if you are confident enough, just edit the script with the exact fix.

Restrain answered 13/2, 2021 at 12:55 Comment(3)
Nice one, just bsdtar doesn't work for me, I use unzip instead.Turd
@Turd fill free to share the command line if it's a oneliner and it strips the first directory as wellRestrain
I'm using unzip without any option, unzip doesn't have that --strip-components argument, for those who want to simulate this option can try this: superuser.com/questions/518347/…Turd
D
5

Just solved this issue with IDE, looks pretty simple to me. (Actually this duplicate previous answer but with the picture). Just install sdk tools and everything should work.

enter image description here

Duluth answered 9/11, 2021 at 9:0 Comment(0)
A
4

This happened to me when downloading the standalone command line tools (commandlinetools-mac-6200805_latest) on a new Mac.

Based on all the answers here, I was able to make it work like this

# Define ANDROID_HOME, if not defined already
export ANDROID_HOME="~/Library/Android/sdk"

# Create the folder if missing
mkdir -p $ANDROID_HOME

# Let the tool know that it should use that SDK location. 
sdkmanager --list --sdk_root=$ANDROID_HOME

The docs for the --sdk_root option say "Use the specified SDK root instead of the SDK containing this tool". This made me think that, despite being shipped standalone, the tool expects to be part of a bundle where the SDK is installed aswell.

Annunciator answered 8/4, 2020 at 5:9 Comment(2)
Just specific a folder to --sdk_root works on fedora 29 x86_64 workstation. e.g. ./sdkmanager --version --sdk_root=/home/software/androidsdkSpelaean
still I get error: $ andriod -bash: andriod: command not foundDilks
B
3

I would like to share my experience.

At first I try to explain why directory structure has to look the way shown in this answer - https://mcmap.net/q/66457/-android-command-line-tools-sdkmanager-always-shows-warning-could-not-create-settings . https://stackoverflow.com/users/668455/tristan asked for explanation several times so hope I will clarify the situtation with the next experiment:

1. unpack cmdline-tools to any path, for example c:\Android\tools;
2. create a folder for SDK, let it be c:\Android\SDK;
3. install cmdline-tools (yes, we install cmdline-tools again =)):
    c:\Android\tools\bin\sdkmanager --sdk_root=c:\Android\SDK "cmdline-tools;latest"
4. at this moment we can examine c:\Android\SDK and locate
    the path c:\Android\SDK\cmdline-tools\latest. If we compare
    this folder with the previous version c:\Android\tools we find out
    that they are identical. The new installed c:\Android\SDK\cmdline-tools\latest\sdkmanager works
    without --sdk_root argument so we could initially unpack cmdline-tools
    to cmdline-tools\latest.

One may encounter another issue - Stuck at ".android/repositories.cfg could not be loaded."

Other issues & facts:

1. QtCreator works with another sdkmanager that placed in SDK_ROOT/tools/bin
2. SDK_ROOT/tools/bin/sdkmanager works only with JDK 8
3. Java uses its own storage for certificates and it's not convinient usually.
    Thus one may want to use Windows certificate store. Unfortunately Grandle has the
    issue - https://stackoverflow.com/a/59056537 - so use the following:
    set JAVA_OPTS=-Djavax.net.ssl.trustStoreType=Windows-ROOT -Djavax.net.ssl.trustStore=NUL

To sum up the following recipe for development with Qt can be composed:

1. download commandlinetools-win-6200805_latest.zip
2. extract cmdline-tools so there will be hierarchy
    SDKROOT
        - cmdline-tools
            - latest
                - bin
                    - sdkmanager.bat
                    - ...
                - lib
                - ...
3. install JDK 8. set JAVA_HOME=c:\path\to\java so that %JAVA_HOME%/bin/java.exe exists.
4. set JAVA_OPTS=-Djavax.net.ssl.trustStoreType=Windows-ROOT -Djavax.net.ssl.trustStore=NUL
5. NDK may be downloaded manually or installed with sdkmanager
6. install required components:
    SDKROOT\cmdline-tools\latest\bin\sdkmanager "tools" "build-tools;BUILD_TOOLS_VERSION" "platform-tools" "platforms;ANDROID_VERSION"
7. run qtcreator from console so JAVA_OPTS is taken into account (or set it globaly for windows user or even station)
8. tools -> options -> devices set paths to JDK 8, SDKROOT and NDK
Bloodandthunder answered 24/3, 2020 at 19:14 Comment(0)
B
2

Android SDK Tools now rest in following location: "android_sdk/cmdline-tools/version/bin/";

Therefore to solve this problem in Windows (same can be replicated in other OS), do the following:

  1. Inside your android_sdk folder, create the folder: cmdline-tools and inside it create another folder: version extract / put all your files "/bin /lib NOTICE and sources.properties" files inside this version folder.

  2. Set ANDROID_HOME to your android_sdk folder.

  3. Add to your System Path: android_sdk\cmdlineAndroidSDK\cmdline-tools\version\bin\

Similarly, place your Android SDK Platform Tools inside your android_sdk/platform-tools/ and add corresponding PATH to ENVIRONMENTAL VARIABLES under System Variables

Broadnax answered 23/5, 2020 at 14:52 Comment(2)
No .. its "android_sdk/cmdline-tools/tools/bin/" ??Thriller
for me "android_sdk/cmdline-tools/version/bin/" worked 100% correctly. and it's also mentioned on the android studio website.Broadnax
D
2

Based on updated suggestions from @Jing Li. Here's my version of gitlab-ci.yml

image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "30"
  ANDROID_BUILD_TOOLS: "29.0.2"
  ANDROID_COMMAND_LINE_TOOLS: "6858069"
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - mkdir -p android-sdk-linux/cmdline-tools
  - export ANDROID_SDK_ROOT=$PWD/android-sdk-linux
  - cd android-sdk-linux/cmdline-tools
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_COMMAND_LINE_TOOLS}_latest.zip
  - unzip android-sdk.zip
  - rm android-sdk.zip
  - mv cmdline-tools version
  - echo y | version/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | version/bin/sdkmanager "platform-tools" >/dev/null
  - echo y | version/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
  # temporarily disable checking for EPIPE error and use yes to accept all licenses
  - set +o pipefail
  - yes | version/bin/sdkmanager --licenses
  - set -o pipefail
  - cd ../../
  - chmod +x ./gradlew

cache:
  key: ${CI_PROJECT_ID}
  paths:
    - .gradle/
Donica answered 7/4, 2021 at 9:38 Comment(0)
M
1

This page from Unity 2018 documentation also has a good explanation of resolving this issue, including such points like:

  1. Installing the Android SDK without Android Studio.
  2. Workaround for “Warning: Could not create settings” and “java.lang.IllegalArgumentException”
  3. The trick for Android Studio version 3.6 or newer.
  4. Warning about Java 9 or later, a JDK must be version 8.

https://docs.unity3d.com/2018.4/Documentation/Manual/android-sdksetup.html

Meaganmeager answered 1/4, 2020 at 16:10 Comment(1)
This actually works, all the other answers are very outdated.Collaborationist
P
1

If you are using Linux and at the same time, you don't want to mess your hands with complex workarounds, I recommend you to download and use the Snap version of sdkmanager.

Remember to use androidsdk instead of sdkmanager in the terminal.

Pearcy answered 12/8, 2020 at 8:46 Comment(1)
sudo snap install androidsdk && androidsdk 'platforms;android-34'Kingsize
G
1

Since new updates, there are some changes that are not mentioned in the documentation. After unzipping the command line tools package, the top-most directory you'll get is cmdline-tools. Rename the unpacked directory from cmdline-tools to tools, and place it under $C:/Android/cmdline-tools

now it will look like $C:/Android/cmdline-tools/tools

and it will work perfectly.

Gramnegative answered 7/9, 2022 at 21:54 Comment(0)
B
0

The first requirement of installing SDK (Any method) is to install Java & setting JAVA_HOME path.

Then, SDK command-line tools need installation path without which it throws NullPointerException.
To overcome this just pass the path where you want to install SDK with argument "--sdk_root"
Eg. sdkmanager.bat "platform-tools" "platforms;android-" --sdk_root=

Battled answered 20/4, 2020 at 5:5 Comment(0)
R
0

Working Solution for Ubuntu using Android Studio Here's the working procedure for Ubuntu and Debian like linux :

  1. install Android studio as desribed in their website https://developer.android.com/studio/install
  2. run : flutter config --android-studio-dir <location of android studio> then flutter config --android-sdk /home/user/Android/Sdk (this is the default location of the SDK)
  3. add the bin to your PATH PATH=$PATH:/home/user/Android/Sdk/tools/bin/
  4. Afterwards, run : flutter doctor --android-licenses and accept all licences To check if everything is ok run the doctor in verbos mode as following : flutter doctor -v
Refugio answered 2/8, 2021 at 13:3 Comment(0)
S
0

Here is very basic and simple solution just change the folder structure change main folder name to latest then create a folder named cmdline-tools create new folder inside cmdline called tools and put bin and other data inside tools folder so it will look like this user\latest\cmdline-tools\tools

I have searched alot but it worked for me

Sieracki answered 13/12, 2021 at 5:50 Comment(0)
D
0

as of march 7th 2023 , the SDK manager states: Move the original cmdline-tools directory contents, including the lib directory, bin directory, NOTICE.txt file, and source.properties file, into the newly created latest directory. You can now use the command-line tools from this location.

Dubuffet answered 7/3, 2023 at 19:29 Comment(0)
I
-3

Android Studio is necessary when installing the command line tools even if it's not the editor you use to develop apps with. Unchecking the obsolete packages tab and downloading the tools should do it; that should clear the license issue and you can go back to your favorite IDE (such as VS Code).

Ingeingeberg answered 26/5, 2020 at 14:19 Comment(1)
this isn't the answer to my questionDigastric

© 2022 - 2024 — McMap. All rights reserved.