Installing the Android SDK on a Headless Server

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.

  1. Download the file. Update the URL for new versions.
  2. Unpack wherever you want to install the SDK.
  3. Set up your environment variables. These lines can be added to your ~/.bash_profile:
  4. 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.
  5. 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.
  6. Download by number. Of course, you should replace “1,2,4” below with numbers from the previous step.

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.


Leave a Reply

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