I am installing android SDK to create an automated build server. I got into a problem where many Gradle-based Android projects I manage rely on different build tools version. Some of the projects still requiring old build-tools version (e.g. v19.1.0).
My android-sdk package was downloaded when build-tools version 20 has just released, so that's the only version available to download via android update sdk -u --filter build-tools
.
I have tried to invoke android update sdk -u --filter build-tools-19.1.0
but it didn't work. Is there an easy way to install old version of Android build tools from command line?
Note: installing via GUI is not possible
What you want is to be able to obtain the same functionality of the SDK Manager GUI in a command line.
Issue this command to query all available packages from the repository. The query will return the packages with a index number on the left.
You can use a grep command to narrow your search. For example:
Finally, install the desired package by supplying its index number in this command.
The options have this meaning:
Answering my own question, I have just found that one of the best way to achieve my goal is by using SDK manager Gradle plugin by Jake Wharton.
It's as simple as adding Gradle plugin. Any required SDK packages will be installed on demand to SDK location specified in
local.properties
.This approach works great especially in headless CI environment. Just don't forget to add
ANDROID_HOME
environment variable just in case you don't havelocal.properties
already (which most likely happens on CI environment)Based on: How to install Android SDK Build Tools on the command line? and others here is my version:
Assuming you have downloaded the Android SDK for linux, you have two options to update from command line.
Download using android tool from the sdk
Instead of running the android sdk manager with a GUI, you also have an option to run in headless mode. You just need to specify
-u
(or--no-ui
) flag.To list packages available for installation or upgrade:
To download specific packages you need to specify the number of the item you want to install from the list in the following command:
Example: if I wanted to install andorid sdk build tools revision 23.0.1, I would type in:
Manual download
As not every package (especially the old ones) is listed when you do
android sdk list
, you can also download things manually. You can manually open the XML file that is shown when duringandroid sdk list
- https://dl.google.com/android/repository/repository-11.xmlYou can find there links to various types of things to download, e.g:
To manually download e.g. version 19.0.1 of build tools
Side note (ubuntu):
If you're running debian/ubuntu 64-bit, to run
aapt
you will need to install additional packages:If you're running CentOs (RedHat), to run
aapt
you will need to install additional packages:While running
aapt
, if you get an error with GLIBC 2.14 and you dont wont to upgrade your locale GLIBC. Then u need to download the following packages for sdk (build-tool, platform-tool) :build-tool : http://dl.google.com/android/repository/build-tools_r23.0.2-linux.zip
platform-tool : https://dl.google.com/android/repository/platform-tools_r23.0.1-linux.zip