The sdkmanager is a CLI tool that allows users to view, install, update, and uninstall available packages for the Android SDK.
This tutorial is going to teach you how to install Android SDK Manager on Ubuntu 18.04 using terminal. Earlier we have seen how to Install Android SDK Manager on Ubuntu 16.04.
If you're already using Android Studio, you don't need to use sdkmanager as you can manage your SDK packages from the IDE instead. The sdkmanager tool is provided in the Android SDK Tools package, so we are going to install the latter to be able to use sdkmanager.
Install Android SDK Tools Package
Before installing the preferred tool, we need to update all packages and install JAVA, as the Android SDK requires it to run. To do so you can run the following commands in the order mentioned below:
sudo apt update
sudo apt install default-jdk
Once JAVA is installed on the machine we can run the following command to check the java version and to be sure it has been installed correctly:
java -version
The output must look like this
openjdk version "10.0.1" 2018-04-17 OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)
After successful JAVA installation, we can proceed to the installation of Android SDK. We need to download the binaries from Android Developers Website. If you open the link above in the browser you can find available zip files under the "Command Line Tools only" part. To download binaries from terminal run the command below:
wget https://developer.android.com/studio/#downloads
Once it's installed unzip with the following command
unzip sdk-tools-linux-3859397.zip
A new directory will be created named tools. To complete the installation we need to add the following paths to our PATH environment variable. To do so, you can run the command below:
export PATH=/home/ubuntu/tools:/home/ubuntu/tools/bin:$PATH
If you've downloaded or unzipped the SDK-tools package into other directory, please don't forget to use appropriate paths. To add the directories permanently, just add the line above to the ~/.bashrc
or ~/.profile
files.
Android SDK Manager usage from terminal
Once Android SDK has been installed we can use sdkmanager
tool to view, install, update and uninstall packages for the Android SDK from terminal.
List installed, available packages and updates
To list all installed, available packages and ones that have update we can run:
sdkmanager --list
The output will look like the one below:
Installed packages: Path | Version | Description | Location ------- | ------- | ------- | ------- platform-tools | 27.0.1 | Android SDK Platform-Tools | platform-tools/ tools | 26.0.1 | Android SDK Tools 26.0.1 | tools/ Available Packages: Path | Version | Description ------- | ------- | ------- add-ons;addon-g..._apis-google-15 | 3 | Google APIs add-ons;addon-g..._apis-google-16 | 4 | Google APIs add-ons;addon-g..._apis-google-17 | 4 | Google APIs add-ons;addon-g..._apis-google-18 | 4 | Google APIs add-ons;addon-g..._apis-google-19 | 20 | Google APIs add-ons;addon-g..._apis-google-21 | 1 | Google APIs add-ons;addon-g..._apis-google-22 | 1 | Google APIs add-ons;addon-g..._apis-google-23 | 1 | Google APIs add-ons;addon-g..._apis-google-24 | 1 | Google APIs add-ons;addon-g...e_gdk-google-19 | 11 | Glass Development Kit Preview ... system-images;a...s_playstore;x86 | 2 | Google Play Intel x86 Atom Sys... system-images;a...laystore;x86_64 | 2 | Google Play Intel x86 Atom_64 ... tools | 26.1.1 | Android SDK Tools Available Updates: ID | Installed | Available ------- | ------- | ------- tools | 26.0.1 | 26.1.1 done
You can have issues when running this command. E.g. the output of the command can be an error like the one below:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156) at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75) at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81) at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:117) at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ... 5 more
To resolve this issue edit the sdkamanger script which is located in bin folder of the installation folder (in our case the full path to the file was /home/ubuntu/tools/bin/sdkamanager
) and add the following line in the 31st line:
-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
After the editing, that line must look like below:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Once you've edited the file and saved you can run the sdkmanager --list
command again. Only installed packages will be shown and another error message will appear which will be like the one below:
Warning: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty Warning: Failed to download any source lists! Warning: File /home/ubuntu/.android/repositories.cfg could not be loaded.
Actually there are two separate errors in the message above. One is related to secure connection due to which it cannot view available packages and check the packages for updates. The second one says that sdkmanager cannot load /home/ubuntu/.android/repositories.cfg
file.
To fix the errors we create the repositories.cfg file (as it hasn't been created by default) and run the sdkmanager --list
command with --no_https
flag. Run the following commands in the order below:
touch /home/ubuntu/.android/repositories.cfg
sdkmanager --no_https --list
After running these commands you will be able to see the output shown above in this article.
Install, update and uninstall packages using sdkmanager
To install package, run the following command:
sdkmanager --no_https [package_name]
If you want to uninstall several packages you can add them to a file and use --package_file flag. For example
sdkmanager --no_https --package_file=/path/to/package_file
Note that package_name must be from available packages list and if you don't use no_https
flag it will throw the same error when we ran the sdkmanager --list
command.
To update all packages, you can run:
sdkmanager --no_https --update
Note that if you update SDK tools you need to edit /home/ubuntu/tools/bin/sdkamanager
file again and add -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
in the 31st line, as the mentioned above file will be fetched from the server and will become the default one.
To uninstall package, run the command below:
sdkmanager --uninstall [package_name]
or
sdkmanager --uninstall --package_file=/path/to/package_file
Read also :
The installation of Android SDK Manager itself is very simple, but during the process you may face different issues which are related to JAVA. However, there are workarounds described for types of issues you can face. So using this tutorial you can be sure that you'll make it work.
Thanks for this article! Worked for me.
What would be the proper way to enable https?
Actually the issue comes from JDK version. if you install default-jdk it installs openjdk11, which causes the problems described in the article. to avoid https problem you can use openjdk8. try to remove jdk11 and install jdk8. This will solve the issue
The https issue seems to have been fixed? No longer needing the --no_https option?
Hi,
Thanks for your howto. It works for me.
Please advise;
1)
Is it possible running GUI Android SDK Manager similar to;
Run WhatsApp on Android SDK without a phone
https://eureka.ykyuen.info/2012/02/05/run-whatsapp-on-android-sdk-without-a-phone/
2)
How to install Android AVD Manager? Thanks
Regards
SL
Hi! I got the message when i wanna install platform-tools with this command " sdkmanager "platform-tools" "platforms:Android-28" "
Here is the message
Warning: Failed to read or create install properties file.
could you help me, please!
Hi Firdaus,
Looks like android directory doesn't have proper permission to write. find directory and change permissions
when I run this command "sdkmanager --list" I get this answer
" Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found"
Hi Hamatane,
This version of Java using ? Module java.se.ee is deprecated. Try using a different version of Java.
https://docs.oracle.com/javase/10/docs/api/java.se.ee-summary.html
These instructions do not work anymore (in my experience). I am running in a relatively newly created VM using Ubuntu 18.04 with Android Studio installed. I am getting the following error:
developer@spaceinvader-dev:~$ ./Android/Sdk/tools/bin/sdkmanager --list
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
developer@spaceinvader-dev:~$ which java
/usr/bin/java
developer@spaceinvader-dev:~$ java --version
openjdk 11.0.3 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)
hi, Michael! look at his track on this forum they found a work-arround for ubuntu 18 and openjdk 11
https://issuetracker.google.com/issues/136592597#comment2
I hope it can work for somebody
RE: Android SDK Manager
Nice article! Thank you. Very helpful.
There *IS* no "tools" vs "full" option anymore. Google only provides the full, bloated sack of code now. No basic, simple, small package. Probably because it's too much mental effort for Google to provide two versions.
For install use this command
sudo snap install androidsdk