Setting up a remote build environment for an Android project wasn’t something i thought I’d need to do but as it turned out today, I did need it and after consulting some pages online, it wasn’t so difficult to achieve. I’m documenting this to make my future attempts easier to accomplish and also to help anyone out there with the required information.
The recommended way to install the Android SDK (at the time of this writing) is by installing Android Studio but as I’m using a DigitalOcean droplet, there’s no GUI for me to interact with the installer. Fortunately for us, the official Android Studio download page also has a link (at the bottom of the page) to download just the command-line tools for Android.
Scroll down to the bottom of the page and copy the download link for Linux. Next, from your ssh terminal, create the /home/android-sdk directory. From within that directory, do execute:
$ wget https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
Replace the url with the one you copied from the downloads page so you have the latest version. Once this is done, unzip the zip archive so that you have the following directory structure:
/home |--android-sdk |--tools |--apps |--bin |--bin64 |--lib |--lib64 |--proguard |--qemu |--support |--templates
Setup environment variables:
export ANDROID_HOME=/home/android-sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools
Next, display a list of available packages by running:
$ sdkmanager --list
This would show you the list of packages that you can install from a host of different sources. The sdkmanager documentation shows how to use the tool.
To install the platforms and build-tools needed, just run:
$ sdkmanager "build-tools;25.0.2" "build-tools;25.0.1" "platforms;android-24" "platforms;android-25"
And that’s all.
Your Android SDK is setup successfully.