How to Install Android SDK Manager on Ubuntu 16.04

In this article, we will see how to install Android SDK manager on ubuntu 16.04 with the command line. The sdkmanager is a command line tool that allows you to view, install, update, and uninstall packages for the Android SDK. If you're using Android Studio, then you do not need to use this tool and you can instead manage your SDK packages from the IDE. Let's start with installation.

Install Android SDK on Ubuntu 16.04

Step 1: Before starting the installation of Android SDK, we need to install java on the machine. Android SDK requires java to run. Execute below command to install java on machine

$ apt-get update
$ apt-get install default-jdk

You can check the installation status by checking the version of installed java, Execute below command to check the installed version if it gives version in output, Java is installed successfully.

$ java -version

If you have already java version installed on the machine, please ignore this step.

Step 2: Now, download sdkmanager binaries from the Download page of Android website. You will get link of binaries at the page under command line tools. After copying the link, execute below command to download binaries.

$ wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip

You need to replace the link with your copied one in above command.

Step 3: Extract the downloaded zip file on your choice of directory. I am extracting it in the home directory.

$ unzip sdk-tools-linux-3859397.zip

One new directory named 'tools' will be created. We have successfully installed Android SDK. Now, let's configure it.

Step 4: Add SDK tools directory in PATH environment variable to make executable available globally. Add below line ~/.bashrc or ~/.profile file to make it permanent.

$ export PATH=/opt/pradip/tools:/opt/pradip/tools/bin:$PATH

Use relative path according to your installation directory in above line.

Usage of Android SDK manager from command line

List packages

You can list installed and available packages by executing below commands. It will show installed packages, available packages and available updates on installed packages.

$ sdkmanager --list
Installed packages:
  Path                 | Version | Description                  | Location
  -------              | ------- | -------                      | -------
  build-tools;19.1.0   | 19.1.0  | Android SDK Build-Tools 19.1 | build-tools/19.1.0/
  platforms;android-27 | 1       | Android SDK Platform 27      | platforms/android-27/
  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-24 | 1            | Google APIs
  add-ons;addon-g...e_gdk-google-19 | 11           | Glass Development Kit Preview
  build-tools;19.1.0                | 19.1.0       | Android SDK Build-Tools 19.1
  build-tools;20.0.0                | 20.0.0       | Android SDK Build-Tools 20
  :
  :
  
  build-tools;27.0.1                | 27.0.1       | Android SDK Build-Tools 27.0.1
  cmake;3.6.4111459                 | 3.6.4111459  | CMake 3.6.4111459
  docs                              | 1            | Documentation for Android SDK
  emulator                          | 26.1.4       | Android Emulator
  extras;android;gapid;1            | 1.0.3        | GPU Debugging tools
  extras;android;gapid;3            | 3.1.0        | GPU Debugging tools
  extras;android;m2repository       | 47.0.0       | Android Support Repository
  extras;google;auto                | 1.1          | Android Auto Desktop Head Unit...
  :
  :
  Layout for Android 1...
  extras;m2reposi...nt-layout;1.0.1 | 1            | ConstraintLayout for Android 1...
  extras;m2reposi...nt-layout;1.0.2 | 1            | ConstraintLayout for Android 1...
  lldb;2.0                          | 2.0.2558144  | LLDB 2.0
  lldb;2.1                          | 2.1.2852477  | LLDB 2.1
  lldb;2.2                          | 2.2.3271982  | LLDB 2.2
  lldb;2.3                          | 2.3.3614996  | LLDB 2.3
  lldb;3.0                          | 3.0.4213617  | LLDB 3.0
  ndk-bundle                        | 15.2.4203891 | NDK
  patcher;v4                        | 1            | SDK Patch Applier v4
  platform-tools                    | 26.0.2       | Android SDK Platform-Tools
  platforms;android-10              | 2            | Android SDK Platform 10
  platforms;android-11              | 2            | Android SDK Platform 11
  :
  :
  platforms;android-9               | 2            | Android SDK Platform 9
  sources;android-15                | 2            | Sources for Android 15
  :
  :
  sources;android-26                | 1            | Sources for Android 26
  system-images;a...ult;armeabi-v7a | 4            | ARM EABI v7a System Image
  :
  :
  system-images;a...s_playstore;x86 | 1            | Google Play Intel x86 Atom Sys...
  tools                             | 26.1.1       | Android SDK Tools

Available Updates:
  ID      | Installed | Available
  ------- | -------   | -------
  tools   | 26.0.1    | 26.1.1
done

Install packages

sdkmanager packages [options]
Here, the 'packages' argument is an SDK-style path as shown with the --list command(Refer output of 'sdkmanager --list' command and check path column) , wrapped in double quotes (for example, "build-tools;24.0.2" or "platforms;android-25")

$ sdkmanager "platforms;android-25" "build-tools;24.0.2" done

Alternatively, you can give package_file as argument which contains all the packages which needs to be installed.

$ sdkmanager --package_file=package_file [options]

To uninstall the existing packages, all you need to do is to insert simple --uninstall flag as shown below

$ sdkmanager --uninstall packages [options]
$ sdkmanager --uninstall --package_file=package_file [options]
sdkmanager --uninstall "build-tools;22.0.1"
done

Update all installed packages

$ sdkmanager --update [options]
$ sdkmanager --update
done

We have successfully installed and configured Android SDK on ubuntu 16.04. Android studio is required for the development of Android, For building application only, sdkmanager is sufficient. If you want to use your machine as build machine only to generate android apk instead of development, Then this approach is ideal for you. Please share your thoughts in the comment section.

About Pradip Sakhavala

Pradip is a Linux system administrator, an ardent believer in sharing and contributing to open source community. He has a keen interest in DevOps And IoT. He likes to discuss technical stuff anytime. He has started sharing his experience by blogs recently.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.