How to set up a mobile build server: step 2

  1. Introduction
  2. Server-side and client-side: (Optional) Create and configure an user on the build server
  3. Server-side: Install and configure the Android SDK
  4. Server-side: Install and configure cordova/ionic
  5. Client-side: Automate the build process

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

    wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -O /tmp/android-sdk.tgz
I wrote a small python script which parse the html page and get the link of the most recent SDK version. Download it

We extract the android sdk into a new hidden directory in the home named .android-sdk.

    mkdir -p ~/.android-sdk
    tar xvf /tmp/android-sdk.tgz -C ~/.android-sdk

Configure the PATH

Now we have to add the android executables such as android (SDK Manager) and adb to the PATH. An ANDROID_HOME variable is also necessary.

    echo "ANDROID_HOME=~/.android-sdk/android-sdk-linux" >> ~/.${SHELL##*/}rc
    echo "PATH=$PATH:~/.android-sdk/android-sdk-linux/tools:~/.android-sdk/android-sdk-linux/platform-tools" >> ~/.${SHELL##*/}rc

Reload your shell configuration file with

    source ~/.${SHELL##*/}rc

to update the PATH for the current ssh session.

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

Screen Shot 2015-12-31 at 22.02.53

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.

Go to the third part

Script

Download it. Don’t forget: it’s a server-side script !

Leave a Reply

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