Android: Easy (and free) continuous integration with Travis-CI

Wednesday, Jan 13, 2016| Tags: android, ci

Ever seen those fancy green icons on Github, saying things like “Build Passing”? That’s a service like Travis-CI stating that the current project branch builds.

In this article I will explain you how to integrate it with your Android projects, with some improvements I’ve had to face.

This service is free for open source projects, and so easy to use that you will wonder why didn’t you use it before.

The first step is to register in Travis-CI, and you can do that with your Github account.

Once you have selected the project you want, you need to add the .travis.yml file to your code.

Adding the configuration file

The following Gist shows the .travis.yml file from my example project:

As you can see, my file is a bit different to what Android tutorial explains.

  • In my configuration file, I specify the build tools version to match my build.gradle file.
  • If you are using the support library, you’ll need to add -extra-android-m2repository like I do.
  • I’ve also removed the connectedCheck from the original example, as I have no interest on running tests with a real device at the moment.
  • If you encounter a permission denied error when running your script, you need to tell Travis-CI to fix the execution permission on the gradlew script file. You can do that with the before_install chmod command.

Push it!

The last step is just pushing your changes with the new configuration file. Travis-CI will start building immediately and will present you with your results.

If you want to add the “Build Passing” icon, just copy the image location on your project page into your file.



Contact with me