Server-side: Install and configure the Android SDK

It’s time now to install the Android SDK with the command line interface.

If you want to set up a build server for Mac OS X, you only need to download XCode and the iOS SDK will be downloaded. For LaTeX, see the appropriate install section for your distribution. At the end, some links will be listed for more informations about these alternatives

Each commands must be executed on the server so first connect you on the server.

Download and install the Android SDK

Go to the Android website to download the SDK. Copy the link for the Linux version and use wget.
The actual version is r24.4.1, so the command is

Choose SDK API to install

SDK is installed and the PATH is configured. Now we have to install which SDK versions we want to install.

The SDK manager can be managed with the android command. By default, it launched the SDK Manager window.
To use the SDK manager in command line, you have to add the –no-ui at the end of each andoid command.

For example, to list all sdk versions, you use

android list sdk --no-ui

and you get a similar output than

The numbered list in the output let you choose which SDK API you want to install with the command android update sdk -u -a -t .

First we update the sdk with the command

android update sdk --no-ui

Accept the licence and as it’s the first time you launch this command, it will download the last Android SDK API (Now: Android 6.0 ie API 23).

If you want to install more SDK API, use

android update sdk -u -a -t <package no.>

where is the number in the previous numbered list. (-u is a shortcut –no-ui, -t for filters and -a for all, see android -h).

With my previous screenshot, if you want to install the API for Android 5.1.1 (API 22), you use

android update sdk -u -a -t 4

Install the API you want.

And now ?

The SDK is installed, only using the command line. Great !
Now it’s time to configure cordova and ionic. It would be a small step.

Server-side and client-side: (Optional) Create and configure an user on the build server

In this part, we will create a new user and configure ssh access. It’s an optional part because you can use an existing user.
I chose to separate the user because I think an user on a server must create for only one thing.
On top of that, as I said in the introduction, this method can be used for a C, LaTeX (or anything else) build server. An user for each build method is better in this case.

The user will be called android-sdk.

It’s the only part of this tutorial you need root access to create the user

Server-side: Create the user

Connect to the server and create a new user:

adduser android-sdk

You’ll be prompted for some informations such as a name, full name, and a password.

Client-side: create a ssh key and add it to the server

To avoid having to type the password each time we push, we create a ssh key and add it to the android-sdk’s authorized keys.

Why a mobile build server ?

To develop mobile applications whether for Android, iOS, Tizen or Windows Phone, we need to use the SDK for the appropriate platform. The size of these SDK is more than 1Go for the basics and it can reach around 10-15Go if we download sdk for different versions.

Frequently, in a company, several developers works on a mobile project and it’s very annoying to download the SDK on each workstation. An other case it’s when you work with different OS or different computers: you need to download the SDK multiple times.

Centralized the SDK

A solution is to install the SDK only once on a server which will compile and build the archive for the platform. A mobile project will be in a git repository which will be on the server. The project will be compiled and the archive will be sent to the developer. It will follow this simple process:

Server-side: Create a git repository on the server

Client-side: Clone the repository, work on it, commit and push.

Client-side: Execute a script which will build the project on the server and copy locally the remote archive (apk, ipa, etc).

I will present this solution for the Android SDK which is the easiest to put in place. More specifically the server will be a solution for decentralized cordova/ionic build system.

No graphical interface is needed. This process could be used on an old server, a raspberry pi or anything else. Just need a terminal.

Wait… Other solutions like a docker container or continuous integration system exist. What’s the difference ?

There’re some docker images like this which does the job. Even if I like docker and use it, we must download the image, run it and it takes some place and resources (not a lot) and we don’t have always these resources.

Generally, continuous integration system provide more than we need. And when we want to modify a behavior, we wast time to learn how it’s working. Also some continuous integration system needs some specific resources requirement.

An other point is this method doesn’t require root privileges (for Android SDK): it could be used independantly by a user.

Last this method works on Mac OS X server and only the build script (see below) must be changed. The Mac OS X script will also be given.

No root privileges required, no need a lot of resources, easy to install and to use, no graphical interface needed.

This tutorial is tested and developed for a ssh server running on Linux with git, wget and npm installed (cordova/ionic).

Now, let’s go !

This “How-To” tutorial will be separated into 3 parts for the server configuration and a script for the client.