If you want to set up a remote build machine for an Android project, one of the first obstacles you’ll encounter is how to install the SDK from the command line. Both the SDK installer and AVD Manager are designed to be run graphically. Fortunately, there are some options for command line setups.
First thing you’ll need to do is download the SDK tools. You probably just need the SDK Tools tgz file for a linux install. You do not need the ADT Eclipse plugin, nor the ADT bundle. Those all need a GUI.
Then, after unpacking that file, you’ll need to set up the environment variables and install the actual platform SDKs. There are SDKs for the different APIs you can target (ie, API 15, API 19, etc), so you’ll need to know what you’re aiming at. Google has some old information about how to install those SDKs on a headless machine, but here are all the steps themselves, as well as some caveats.
- Download the file. Update the URL for new versions.
1$ wget http://dl.google.com/android/android-sdk_r23-linux.tgz
Unpack wherever you want to install the SDK.
1$ tar -xzf android-sdk_r23-linux.tgz
Set up your environment variables. These lines can be added to your ~/.bash_profile:
123export ANDROID_HOME=/usr/local/android-sdk-linuxexport PATH=$PATH:$ANDROID_HOME/toolsexport PATH=$PATH:$ANDROID_HOME/platform-tools
Get the list of available packages. This command will fetch from a bunch of sources, and then present a long, numbered list of packages you can install.
1$ android list sdk
- Pick out the numbers for the packages you need. You’ll need at least the build-tools and the platform-tools, as well as the SDKs for any API versions you’re targeting.
Download by number. Of course, you should replace “1,2,4” below with numbers from the previous step.
1$ android update sdk --no-ui --filter 1,2,4
Couple of warnings:
- The package numbering will change after you start installing packages because the installed packages don’t show up in the list. You need to re-run android list sdk to get new numbers after any installs or Android updates.
- Running android update sdk --no-ui without the --filter parameter will install everything. There’s a lot of documentation, sample code, etc, that a remote build server won’t need. Save that stuff for your dev machine.