[android] How to install Android SDK Build Tools on the command line?

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.

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to sdk

I am receiving warning in Facebook Application using PHP SDK Has been compiled by a more recent version of the Java Runtime (class file version 57.0) Difference between OpenJDK and Adoptium/AdoptOpenJDK Error:Failed to open zip file. Gradle's dependency cache may be corrupt Can't accept license agreement Android SDK Platform 24 Automatically accept all SDK licences Android SDK location should not contain whitespace, as this cause problems with NDK tools Android SDK folder taking a lot of disk space. Do we need to keep all of the System Images? "The following SDK components were not installed: sys-img-x86-addon-google_apis-google-22 and addon-google_apis-google-22" Can't find SDK folder inside Android studio path, and SDK manager not opening

Examples related to android-build

Installation failed with message Invalid File failed to find target with hash string android-23 What is the difference between compileSdkVersion and targetSdkVersion? Gradle, Android and the ANDROID_HOME SDK location Android Studio: Plugin with id 'android-library' not found How to install Android SDK Build Tools on the command line?

Examples related to aapt

How to install Android SDK Build Tools on the command line? How to view AndroidManifest.xml from APK file?

Examples related to build-tools

How can I install the VS2017 version of msbuild on a build server without installing the IDE? Could not resolve all dependencies for configuration ':classpath' How to install Android SDK Build Tools on the command line? ant warning: "'includeantruntime' was not set"