Android Command line tools sdkmanager always shows: Warning: Could not create settings - android
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
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:
Download latest Command line tools from android i.e. commandlinetools-win-6200805_latest.zip
Unzip the downloaded file
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
Create ANDROID_HOME environment variable for directory that stores the cmdline tools directory location like:
C:\YourLocationWhereYouStoreTheDirectory\android\cmdline-tools\latest
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.
Install Android-SDK.
sudo apt install android-sdk
After the instalation you will have a folder called android-sdk in /usr/lib
Create a folder called cdmline-tools inside the android-sdk folder
sudo mkdir /usr/lib/android-sdk/cmdline-tools
Download the Android command line tools zip from here (https://developer.android.com/studio?hl=en-419#downloads)
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
Go to you home dir and edit your .profile
nano .profile
Create an ANDROID_SDK_ROOT variable
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
Put the sdkmanager folder in your path
export PATH=$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$PATH
Save and Exit
Reload you profile
. ~/.profile
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.
Simple Solution:
Open Android Studio Tools Menu,
SDK Manager In the window that comes
up there are inner panels,
Choose SDK Tools panel Tick Android SDK Command-line Tools
Choose Apply button near the bottom of the window
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
[...]
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"
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)
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.
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.
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:
Opening sdkmanager.bat by notepad++
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
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://stackoverflow.com/a/60460681/1758733 .
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
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.
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:
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.
Set ANDROID_HOME to your android_sdk folder.
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
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/
This page from Unity 2018 documentation also has a good explanation of resolving this issue, including such points like:
Installing the Android SDK without Android Studio.
Workaround for “Warning: Could not create settings” and “java.lang.IllegalArgumentException”
The trick for Android Studio version 3.6 or newer.
Warning about Java 9 or later, a JDK must be version 8.
https://docs.unity3d.com/2018.4/Documentation/Manual/android-sdksetup.html
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.
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=
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.
Working Solution for Ubuntu using Android Studio
Here's the working procedure for Ubuntu and Debian like linux :
install Android studio as desribed in their website
https://developer.android.com/studio/install
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)
add the bin to your PATH PATH=$PATH:/home/user/Android/Sdk/tools/bin/
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
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
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).
Related
Gitlab CI - Android Sdk tools?
I use this Link for add gitlab CI in my android project. The CI work but I don't understand this part : ANDROID_SDK_TOOLS: "4333796" In the tutorial, android SDK tool is the last version available. ANDROID_SDK_TOOLS is a little funny. It's what version of the command line tools we're going to download from the official site. So, that number really just comes from the latest version available there. Installing packages. But when click on the link, they send me in android studio download page. How can i find the version code to put here ? Is it important to change it ? I also tried with sdkmanager.bar --list in SDK > tool > bin directory ERROR: JAVA_HOME is set to an invalid directory: D:\Software\JDK\openjdk-15_windows-x64_bin\jdk-15\bin Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
At the download page you'll find the "Command line tools only" section. The file name ends with the version number. As of now this is: 8092744 (it'll change in the future). The name of the download URL and the zipped directory have been changed though, so you'll need to update your ci file accordingly. Using the template in the linked tutorial, the file could look like this (I only build a debug apk, you can add release versions too ofc, just like in the tutorial): image: openjdk:8-jdk variables: ANDROID_COMPILE_SDK: "31" ANDROID_BUILD_TOOLS: "29.0.2" ANDROID_SDK_TOOLS: "8092744" 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/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null - echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ "platform-tools" >/dev/null - echo y | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ "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/cmdline-tools/bin/sdkmanager --sdk_root=android-sdk-linux/cmdline-tools/latest/ --licenses - yes | android-sdk-linux/cmdline-tools/bin/sdkmanager --sdk_root=/builds/pauni/lara/android-sdk-linux --licenses - set -o pipefail stages: - build assembleDebug: stage: build script: - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/
Android SDK on Alpine - adb No such file or directory
I'm trying to build an Alpine image containing the Android SDK - specifically, the platform-tools package. My Dockerfile does the following: Installs Java and sets JAVA_HOME (needed for Android). Downloads the Android SDK tools from Google. Unzips the package. Sets ANDROID_HOME. Also sets PATH so the sdkmanager executable can be used. Installs platform-tools using sdkmanager. Adds platform-tools to PATH. platform-tools contains an executable named adb, but for some reason it cannot be seen. Running adb returns: bash: /android-sdk/platform-tools/adb: No such file or directory Here is my Dockerfile: FROM alpine:latest # Install bash and java RUN apk update RUN apk add bash openjdk8 ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk ENV PATH="$PATH:$JAVA_HOME/bin" # Download Android SDK and set PATH RUN mkdir /android-sdk RUN wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && unzip *.zip -d /android-sdk && rm *.zip ENV ANDROID_HOME="/android-sdk" ENV PATH="$PATH:$ANDROID_HOME/tools/bin" # Install platform-tools RUN yes | sdkmanager "platform-tools" ENV PATH="$PATH:$ANDROID_HOME/platform-tools" RUN adb version # throws error: adb not found I've looked at this question but the problem should be fixed with platform-tools v24.0 and higher.
Alpine uses musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. adb is compiled with glibc, so it won't be able to run in Alpine, which usually results in the error: No such file or directory. You can verify that a file is compiled with glibc by running file <path to file> | grep "interpreter /lib64/ld-linux-x86-64.so.2".
This may help, although the Gradle daemon randomly crashes for me on Alpine Linux when using the compatibility layer. gcompat is the go-to compatibility layer for Alpine users. apk add gcompat After that you run your binaries as normal. Source: https://wiki.alpinelinux.org/wiki/Running_glibc_programs
You can install android-tools like so: RUN apk add \ android-tools \ --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing The key is to set the --repository as shown, as it's only in the edge testing repo. I don't think it includes the whole SDK, so may need to download and unzip as well for other tools. I don't know if this will handle everything you want, but adb prints a help document at least.
Travis: how to know android sdk/ndk path?
My android project is built with Ant and i have to edit ant.properties manually file to pass sdk.path variable pointing to android sdk directory. i'm going to change it to get sdk path from environment variable to make build possible on Travis CI. What is android sdk variable for this? Also i have some jni code to be built with android ndk, so the similar question - what is env variable for android ndk on Travis?
Don't use the Travis's Android support; it uses the old 'android' CLI instead of the new sdkmanager CLI that supports installing the NDK. Do something like: before_install: - cd $HOME - wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O $HOME/android-sdk.tgz - mkdir android - unzip android-sdk.tgz -d android/sdk - export PATH=$PATH:$HOME/android/sdk/tools:$HOME/android/sdk/tools/bin - cd build/<your-build-directory> And then in the 'install' section: install: - echo y | sdkmanager 'ndk-bundle' - echo y | sdkmanager 'cmake;3.6.3155560' - export ANDROID_HOME=$HOME/android/sdk - export ANDROID_NDK_HOME=$HOME/android/sdk/ndk-bundle You can use the sdkmanager to install anything else you need. The benefit over the other answer is that this will grab the latest version of the NDK. Finally, then you can set the environment variables ANDROID_HOME and ANDROID_NDK_HOME, and pass it to your specific environment. Hope it helps.
Travis seems to provide Android support in beta. Android SDK can be found in /usr/local/android-sdk. However it seems that Android NDK is not provided and can't be found in /usr/local/android-ndk. The simple (and expensive walkaround for Travis) is to download/extract/use it right while building like this: before_script: - export NDK_VERSION=r10e - curl -L http://dl.google.com/android/ndk/android-ndk-${NDK_VERSION}-linux-x86_64.bin -O - chmod u+x android-ndk-${NDK_VERSION}-linux-x86_64.bin - ./android-ndk-${NDK_VERSION}-linux-x86_64.bin > /dev/null - rm android-ndk-${NDK_VERSION}-linux-x86_64.bin - export ANDROID_NDK_HOME=`pwd`/android-ndk-${NDK_VERSION} - export PATH=${ANDROID_NDK_HOME}:${PATH} Feel free to comment this solution if you have a better one.
You can export the Android variables using this command as well as Clive Lee's method env: global: - ANDROID_HOME=$HOME/android/sdk - ANDROID_NDK_HOME=$HOME/android/sdk/ndk-bundle
How to install Android SDK on Ubuntu?
For my Ubuntu machine, I downloaded the latest version of Android SDK from this page. After extracting the downloaded .tgz file, I was trying to search for installation instructions and found: To get started on Linux: Unpack the .zip file you've downloaded. The SDK files are download separately to a user-specified directory. Make a note of the name and location of the SDK directory on your system—you will need to refer to the SDK directory later when using the SDK tools from the command line. What exactly are we supposed to do?
Option 1: sudo apt update && sudo apt install android-sdk The location of Android SDK on Linux can be any of the following: /home/AccountName/Android/Sdk /usr/lib/android-sdk /Library/Android/sdk/ /Users/[USER]/Library/Android/sdk Option 2: Download the Android Studio. Extract downloaded .zip file. The extracted folder name will read somewhat like android-studio To keep navigation easy, move this folder to Home directory. After moving, copy the moved folder by right clicking it. This action will place folder's location to clipboard. Use Ctrl Alt T to open a terminal Go to this folder's directory using cd /home/(USER NAME)/android-studio/bin/ Type this command to make studio.sh executable: chmod +x studio.sh Type ./studio.sh A pop up will be shown asking for installation settings. In my particular case, it is a fresh install so I'll go with selecting I do not have a previous version of Studio or I do not want to import my settings. If you choose to import settings anyway, you may need to close any old project which is opened in order to get a working Android SDK. From now onwards, setup wizard will guide you. Android Studio can work with both Open JDK and Oracle's JDK (recommended). Incase, Open JDK is installed the wizard will recommend installing Oracle Java JDK because some UI and performance issues are reported while using OpenJDK. The downside with Oracle's JDK is that it won't update with the rest of your system like OpenJDK will. The wizard may also prompt about the input problems with IDEA . Select install type Verify installation settings An emulator can also be configured as needed. The wizard will start downloading the necessary SDK tools The wizard may also show an error about Linux 32 Bit Libraries, which can be solved by using the below command: sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 After this, all the required components will be downloaded and installed automatically. After everything is upto the mark, just click finish To make a Desktop icon, go to 'Configure' and then click 'Create Desktop Entry' source
To install it on a Debian based system simply do # Install latest JDK sudo apt install default-jdk # get latest sdk tools - link will change. go to https://developer.android.com/studio/#downloads and look for "Command line tools only" download from webpage as you will need to accept terms. Then extract. mkdir cmdline-tools mv <folder-you-extracted> android-sdk/cmdline-tools # So after this step is done you will have ~/cmdline-tools/tools with bin/ and lib/ in it. Then add the Android SDK to your PATH, open ~/.bashrc in editor and add the following lines into the file # Export the Android SDK path export ANDROID_HOME=$HOME/cmdline-tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools Run source ~/.bashrc Show all available sdk packages sdkmanager --list Identify latest android platform (here it's 33) and run sdkmanager "platform-tools" "platforms;android-33" Now you have adb, fastboot and the latest sdk tools installed
Android SDK Manager sudo snap install androidsdk Usage You can use the sdkmanager to perform the following tasks. List installed and available packages androidsdk --list [options] Install packages androidsdk packages [options] The packages argument is an SDK-style path as shown with the --list command, wrapped in quotes (for example, "build-tools;29.0.0" or "platforms;android-28"). You can pass multiple package paths, separated with a space, but they must each be wrapped in their own set of quotes. For example, here's how to install the latest platform tools (which includes adb and fastboot) and the SDK tools for API level 28: androidsdk "platform-tools" "platforms;android-28" Alternatively, you can pass a text file that specifies all packages: androidsdk --package_file=package_file [options] The package_file argument is the location of a text file in which each line is an SDK-style path of a package to install (without quotes). To uninstall, simply add the --uninstall flag: androidsdk --uninstall packages [options] androidsdk --uninstall --package_file=package_file [options] Update all installed packages androidsdk --update [options] Note androidsdk it is snap wraper of sdkmanager all options of sdkmanager work with androidsdk Location of installed android sdk files : /home/user/AndroidSDK See all sdkmanager options in google documentation
UPDATE: This method is no longer recommended and installation is as easy as downloading it from the official website, then running the downloaded binary. ORIGINAL ANSWER: There is no need to download any binaries or files or follow difficult installation instructions. All you really needed to do is: sudo apt update && sudo apt install android-sdk Update: Ubuntu 18.04 only
I can tell you the steps for installing purely via command line from scratch. I tested it on Ubuntu on 22 Feb 2021. create sdk folder export ANDROID_SDK_ROOT=/usr/lib/android-sdk sudo mkdir -p $ANDROID_SDK_ROOT install openjdk sudo apt-get install openjdk-8-jdk download android sdk Go to https://developer.android.com/studio/index.html Then down to Command line tools only Click on Linux link, accept the agreement and instead of downloading right click and copy link address cd $ANDROID_SDK_ROOT sudo wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip sudo unzip commandlinetools-linux-6858069_latest.zip move folders 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. set path PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin This had no effect for me, hence the next step browse to sdkmanager cd $ANDROID_SDK_ROOT/cmdline-tools/tools/bin accept licenses yes | sudo sdkmanager --licenses create build Finally, run this inside your project chmod 777 gradlew sudo ./gradlew assembleDebug This creates an APK named -debug.apk at //build/outputs/apk/debug The file is already signed with the debug key and aligned with zipalign, so you can immediately install it on a device. REFERENCES https://gist.github.com/guipmourao/3e7edc951b043f6de30ca15a5cc2be40 Android Command line tools sdkmanager always shows: Warning: Could not create settings "Failed to install the following Android SDK packages as some licences have not been accepted" error https://developer.android.com/studio/build/building-cmdline#sign_cmdline
If you are on Ubuntu 17.04 (Zesty), and you literally just need the SDK (no Android Studio), you can install it like on Debian: sudo apt install android-sdk android-sdk-platform-23 export ANDROID_HOME=/usr/lib/android-sdk In build.gradle, change compileSdkVersion to 23 and buildToolsVersion to 24.0.0 run gradle build
install the android SDK for me was not the problem, having the right JRE and JDK was the problem. To solve this install the JVM 8 (the last fully compatible, for now): sudo apt-get install openjdk-8-jre Next use update-alternative to switch to the jre-8 version: sudo update-alternatives --config java You can revert JVM version when you want with the same update-alternatives command Note that you problably have to do the same after this with javac also (now you have only java command at version 8) first do: sudo apt-get install openjdk-8-jdk next: sudo update-alternatives --config javac After this you can install android SDK that require this specific Java version
sudo add-apt-repository -y ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer oracle-java7-set-default wget https://dl.google.com/dl/android/studio/ide-zips/2.2.0.12/android-studio-ide-145.3276617-linux.zip unzip android-studio-ide-145.3276617-linux.zip cd android-studio/bin ./studio.sh
Install Android Studio with sudo snap install android-studio --classic when you open it for the first time it will install the SDK for you (with options) .
How to install Android SDK Build Tools on the command line?
I want to setup the Android dev environment from command line, and encounter the following issue: wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz after extract the file, run tools/android update sdk --no-ui However, it is too slow on running Fetching https://dl-ssl.google.com/android/repository/addons_list-2.xml The result is that nothing in folder build-tools, and I want is aapt and apkbuilder, since I want to build apk from command line without ant.
By default, the SDK Manager from the command line does not include the build tools in the list. They're in the "obsolete" category. To see all available downloads, use android list sdk --all And then to get one of the packages in that list from the command line, use: android update sdk -u -a -t <package no.> Where -u stands for --no-ui, -a stands for --all and -t stands for --filter. If you need to install multiple packages do: android update sdk -u -a -t 1,2,3,4,..,n Where 1,2,..,n is the package number listed with the list command above
As mentioned in other answers, you can use the --filter option to limit the installed packages: android update sdk --filter ... The other answers don't mention that you can use constant string identifiers instead of indexes (which will change) for the filter options. This is helpful for unattended or scripted installs. Man for --filter option: ... This also accepts the identifiers returned by 'list sdk --extended'. android list sdk --all --extended : Packages available for installation or update: 97 ---------- id: 1 or "tools" Type: Tool Desc: Android SDK Tools, revision 22.6.2 ---------- id: 2 or "platform-tools" Type: PlatformTool Desc: Android SDK Platform-tools, revision 19.0.1 ---------- id: 3 or "build-tools-19.0.3" Type: BuildTool Desc: Android SDK Build-tools, revision 19.0.3 Then you can use the string ids as the filter options to precisely specify the versions you want: android update sdk --filter tools,platform-tools,build-tools-19.0.3 etc
Version 25.2.3 (and higher) of Android SDK Tools package contains new tool - sdkmanager - which simplifies this task of installing build-tools from the command line. It is located in android_sdk/tools/bin folder. Usage (from documentation): List installed and available packages: sdkmanager --list [options] \ [--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary) Use the channel option to include a package from a channel up to and including channel_id. For example, specify the canary channel to list packages from all channels. Install packages: sdkmanager packages [options] The packages argument is an SDK-style path, wrapped in quotes (for example, "build-tools;25.0.0" or "platforms;android-25"). You can pass multiple package paths, separated with a space, but they must each be wrapped in their own set of quotes. Example usage (on my Mac): alex#mbpro:~/sdk/tools/bin$ ls ../../build-tools/ 25.0.0/ alex#mbpro:~/sdk/tools/bin$ ./sdkmanager "build-tools;25.0.2" done alex#mbpro:~/sdk/tools/bin$ ls ../../build-tools/ 25.0.0/ 25.0.2/ You can also specify various options, for example to force all connections to use HTTP (--no_https), or in order to use proxy server (--proxy_host=address and --proxy_port=port). To check the available options, use the --help flag. On my machine (Mac), the output is as following: alex#mbpro:~/sdk/tools/bin$ ./sdkmanager --help Usage: sdkmanager [--uninstall] [<common args>] \ [--package_file <package-file>] [<packages>...] sdkmanager --update [<common args>] sdkmanager --list [<common args>] In its first form, installs, or uninstalls, or updates packages. <package> is a sdk-style path (e.g. "build-tools;23.0.0" or "platforms;android-23"). <package-file> is a text file where each line is a sdk-style path of a package to install or uninstall. Multiple --package_file arguments may be specified in combination with explicit paths. In its second form (with --update), currently installed packages are updated to the latest version. In its third form, all installed and available packages are printed out. Common Arguments: --sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK containing this tool --channel=<channelId>: Include packages in channels up to <channelId>. Common channels are: 0 (Stable), 1 (Beta), 2 (Dev), and 3 (Canary). --include_obsolete: With --list, show obsolete packages in the package listing. With --update, update obsolete packages as well as non-obsolete. --no_https: Force all connections to use http rather than https. --proxy=<http | socks>: Connect via a proxy of the given type. --proxy_host=<IP or DNS address>: IP or DNS address of the proxy to use. --proxy_port=<port #>: Proxy port to connect to. * If the env var REPO_OS_OVERRIDE is set to "windows", "macosx", or "linux", packages will be downloaded for that OS.
ADB Build-Tools Will Not be downloaded automatically, by command android update sdk --no-ui So for installing Buil-Tool type (in console): android list sdk --all Remember the number that is listed before the item and execute the following: android update sdk -u --all --filter <number> commands should be typed in /YourFolder/android-sdk-linux/tools Also for remote folder (server opened by ssh for example) type: **./android** list sdk --all **./android** update sdk -u --all --filter <number> For simple list of ADB packages type in terminal: android list sdk for install all packages: android update sdk --no-ui Or with filters (comma is separator): android update sdk --no-ui --filter 3,5,8,14
A great source of information I came across while trying to install everything Android SDK related from the command line, was this Dockerfile. Inside the Dockerfile you can see that the author executes a single command to install platform tools and build tools without any other interaction. In the case the OP has put forth, the command would be adapted to: echo y | $ANDROID_HOME/tools/android update sdk --all --filter build-tools-21.1.0 --no-ui
If you have sdkmanager installed (I'm using MAC) run sdkmanager --list to list available packages. If you want to install build tools, copy the preferred version from the list of packages available. To install the preferred version run sdkmanager "build-tools;27.0.3"
The "android" command is deprecated. For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager If you do not need Android Studio, you can download the basic Android command line tools from developer.android.com in section Command line tools only. from CLI it should be somfing like: curl --output sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip or wget --output-document sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip After that just unpack the archive to the target folder unzip sdk-tools-linux.zip And now we can install everything you need... ./tools/bin/sdkmanager --install 'build-tools;29.0.2' 'platform-tools' 'platforms;android-29' 'tools' You can get a complete list of packages using the command ./tools/bin/sdkmanager --list Some packages require acceptance of the license agreement. you can accept it interactively or just pass "y" to the input stream, like this(two agreements in case): echo -ne "y\ny" | ./tools/bin/sdkmanager --install 'system-images;android-29;default;x86_64' And of course, for your convenience, you can export variables such as ANDROID_HOME or ANDROID_SDK_ROOT (including doing it in ~/.profile or ~/.bash_profile) or patch the PATH variable - all this is at your discretion. Script example: mkdir /opt/android-sdk cd /opt/android-sdk curl --output sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip unzip sdk-tools-linux.zip echo -ne "y" | ./tools/bin/sdkmanager --install 'build-tools;29.0.2' 'platform-tools' 'platforms;android-29' 'tools' Requirements: curl(or wget) and unzip Troubleshooting: if you see Warning: Could not create settings, you need to have the tools directory inside the cmdline-tools directory inside the ANDROID_HOME (create it if needed with this exact name) see Android Command line tools sdkmanager always shows: Warning: Could not create settings
I just had a heck of a time getting android sdk dependencies installed via command line and since the documentation that comes with the tools and online are woefully lacking, I thought I'd post what I discovered here. I'm working with android sdk r24.4.1 for linux. There are two commands that you can run to list the available packages: android list sdk and the more exhaustive: android list sdk --all The package numbers for specific packages differ for each command above! For example, the former lists package API 23.1 revision 3 as package #3 and the latter lists it as #29. Now, there are two different ways to install using the android command. tools/android update sdk --no-ui --filter <package number> and tools/android update sdk -u -a -t <package number> Given that the install commands each can take the package # as a parameter, which package number do you use? After much online searching and trial and error, I discovered that android update sdk --no-ui --filter uses the package numbers from android list sdk and android update sdk -u -a -t uses the package numbers from android list sdk --all In other words - to install API 23.1 revision 3 you can do either: android update sdk --no-ui --filter 3 or android update sdk -u -a -t 29 Crazy, but it works.
Most of the answers seem to ignore the fact that you may need to run the update in a headless environment with no super user rights, which means the script has to answer all the y/n license prompts automatically. Here's the example that does the trick. FILTER=tool,platform,android-20,build-tools-20.0.0,android-19,android-19.0.1 ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) \ | android update sdk --no-ui --all \ --filter ${FILTER} No matter how many prompts you get, all of those will be answered. This while/sleep loop looks like simulation of the yes command, and in fact it is, well almost. The problem with yes is that it floods stdout with 'y' and there is virtually no delay between sending those characters and the version I had to deal with had no timeout option of any kind. It will "pollute" stdout and the script will fail complaining about incorrect input. The solution is to put a delay between sending 'y' to stdout, and that's exactly what while/sleep combo does. expect is not available by default on some linux distros and I had no way to install it as part of my CI scripts, so had to use the most generic solution and nothing can be more generic than simple bash script, right? As a matter of fact, I blogged about it (NSBogan), check it out for more details here if you are interested.
However, it is too slow on running Yes, I've had the same problem. Some of the file downloads are extremely slow (or at least they have been in the last couple of days). If you want to download everything there's not a lot you can do about that. The result is that nothing in folder build-tools, and I want is aapt and apkbuilder, since I want to build apk from command line without ant. Did you let it run to completion? One thing you can do is filter the packages that are being downloaded using the -t switch. For example: tools/android update sdk --no-ui -t platform-tool When I tried this the other day I got version 18.0.0 of the build tools installed. For some reason the latest version 18.0.1 is not included by this filter and the only way to get it was to install everything with the --all switch.
I prefer to put a script that install my dependencies Something like: #!/usr/bin/env bash # # Install JUST the required dependencies for the project. # May be used for ci or other team members. # for I in android-25 \ build-tools-25.0.2 \ tool \ extra-android-m2repository \ extra-android-support \ extra-google-google_play_services \ extra-google-m2repository; do echo y | android update sdk --no-ui --all --filter $I ; done https://github.com/caipivara/android-scripts/blob/master/install-android-dependencies.sh
I just had this problem, so I finally wrote a 1 line bash dirty solution by reading and parsing the list of aviable tools : tools/android update sdk -u -t $(android list sdk | grep 'Android SDK Build-tools' | sed 's/ *\([0-9]\+\)\-.*/\1/')
Inspired from answers by #i4niac & #Aurélien Lambert, this is what i came up with csv_update_numbers=$(./android list sdk --all | grep 'Android SDK Build-tools' | grep -v 'Obsolete' | sed 's/\(.*\)\- A.*/\1/'|sed '/^$/d'|sed -e 's/^[ \t]*//'| tr '\n' ',') csv_update_numbers_without_trailing_comma=${csv_update_numbers%?} ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) \ | ./android update sdk --all -u -t $csv_update_numbers_without_trailing_comma Explanation get a comma separated list of numbers which are the indexes of build tools packages in the result of android list sdk --all command (Ignoring obsolete packages). keep throwing 'y's at the terminal every few miliseconds to accept the licenses.
Download android SDK from developer.android.com (its currently a 149mb file for windows OS). It is worthy of note that android has removed the sdkmanager GUI but has a command line version of the sdkmanager in the bin folder which is located inside the tools folder. When inside the bin folder, hold down the shift key, right click, then select open command line here. Shift+right click >> open command line here. When the command line opens, type sdkmanager click enter. Then run type sdkmanager (space), double hyphen (--), type list sdkmanager --list (this lists all the packages in the SDK manager) Type sdkmanager (space) then package name, press enter. Eg. sdkmanager platform-tools (press enter) It will load licence agreement. With options (y/n). Enter y to accept and it will download the package you specified. For more reference follow official document here I hope this helps. :)
Build tools could not be downloaded automatically by default as Nate said in https://stackoverflow.com/a/19416222/1104031 post. But I wrote small tool that make everything for you I used "expect" tool as danb in https://stackoverflow.com/a/17863931/1104031 post. You only need android-sdk and python27, expect. This script will install all build tools, all sdks and everything you need for automated build: import subprocess,re,sys w = subprocess.check_output(["android", "list", "sdk", "--all"]) lines = w.split("\n") tools = filter(lambda x: "Build-tools" in x, lines) filters = [] for tool in tools: m = re.search("^\s+([0-9]+)-", tool) tool_no = m.group(1) filters.append(tool_no) if len(filters) == 0: raise Exception("Not found build tools") filters.extend(['extra', 'platform', 'platform-tool', 'tool']) filter = ",".join(filters) expect= '''set timeout -1; spawn android update sdk --no-ui --all --filter %s; expect { "Do you accept the license" { exp_send "y\\r" ; exp_continue } eof }''' % (filter) print expect ret = subprocess.call(["expect", "-c", expect]) sys.exit(ret)
As stated in other responses, the build tools requires the --all flag to be installed. You also better use a -t filter flag to avoid installing ALL the packages but there is no way to filter all the build tools. There are already features requests for these two points in AOSP bug tracker. Feel free to vote for them, this might make them happen some day: https://code.google.com/p/android/issues/detail?id=78765 https://code.google.com/p/android/issues/detail?id=58337
I tried this for update all, and it worked! echo y | $ANDROID_HOME/tools/android update sdk --no-ui
Try 1. List all packages android list sdk --all 2. Install packages using following command android update sdk -u -a -t package1, package2, package3 //comma seperated packages obtained using list command
android update sdk This command will update and install all latest release for SDK Tools, Build Tools,SDK platform tools. It's Work for me.
To setup android environment without installating the whole android studio : Download JDK (version greater than 8) Download gradle from https://gradle.org/install/ Download command line tools from https://developer.android.com/studio scroll down and download command line tools only Setup the necessary environment variables Download the necessary SDK tools