This is a step by step guide to set up the automated build process using Jenkins CI for your Android projects. The following steps assume that you have new hardware with just any flavor of Linux installed. It is also taken into account that you might have a remote machine.

PART I: Initial setup on your machine

  1. Log in via ssh to your Ubuntu machine:

ssh [email protected]

  1. Download a version of the Android SDK on your machine:

wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz

  1. Unzip the downloaded tar file:
> sudo apt-get install tar  
> tar -xvf android-sdk_r24.4.1-linux.tgz
  1. Now you need to install Java 8 on your Ubuntu machine, which is a requirement for Android builds on Nougat. Jenkins would require you to install JDK and JRE 7 using the steps below:
> sudo apt-get install python-software-properties  
> sudo add-apt-repository ppa:webupd8team/java  
> sudo apt-get update  
> apt-get install openjdk-8-jdk
  1. Now install Jenkins on your Ubuntu machine:
> wget -q -O - <https://pkg.jenkins.io/debian/jenkins-ci.org.key> | sudo apt-key add -  
> sudo sh -c 'echo deb <http://pkg.jenkins.io/debian-stable> binary/ > /etc/apt/sources.list.d/jenkins.list'  
> sudo apt-get update  
> sudo apt-get install jenkins
  1. Download the latest supported Gradle version for your Android setup:
> wget <https://services.gradle.org/distributions/gradle-2.14.1-all.zip>  
> unzip gradle-2.14.1-all.zip
  1. Set up Android on your Ubuntu machine. First move to the tools folder in the Android SDK folder downloaded in step 2:
> cd android-sdk-linux/tools **// lists available SDK**  
> android update sdk --no-ui **// Updates SDK version**  
> android list sdk -a | grep "SDK Build-tools" **// lists available build tools**  
> android update sdk -a -u -t 4   **// updates build tools version to one listed as 4 by prev. cmd.**  
> update java
  1. Install Git or any other VCS on your machine:

sudo apt-get install git

  1. Now log in to Jenkins using your internet browser. Type ipAddress:8080 into the address bar.
  2. In order to receive the password for the first-time login, please check the corresponding file as follows (you will need su permissions to access this file):