Setting up Travis CI in Android

Setting up Travis CI in Android

If you are developing using TDD you should run your tests to be sure that you don’t break something in every TDD phase. But we are not perfect and we can commit changes that break our system and we should have something that can alert us if we are doing something wrong asap. This is going to be a short guide on getting set and ready with Travis CI in Android. Before we continue, you need to have an Android Studio project already set up. Now let’s get down to business.


  • Create a github repo for your project
  • Head over to the root of your project and create a .travis.yml (More on this later)
  • Still at the root of your project, create a folder/directory called licenses; this directory will help in exporting your license agreements such as sdk license agreement from your local machine to the build environment.
  • Now head over to your sdk location and locate a folder/directory called licenses, copy its contents then go ahead and paste them inside the licenses folder/directory you created previously at your project root.
  • You’re now set up, just do a git init, add all your files to git then push your code to Github.

Setting up Travis CI

Here is where Continous Integration comes into play. Every time that you push changes into a branch in your system you can check if everything is ok before you merge this branch into Master (assuming you are using git). What to check? Well, this is up to you and your team members to decide.

I keep my promises! , lets now talk about .travis.yml mentioned earlier. So this is just a file that tells your build machine how it should be configured and also provides the necessary tools and information to get your build system up and running.

So how does this file look like? Here’s the code, you can copy paste it but ensure you go through it to have a grasp of what’s going on.

You can decide to paste it directly to your code then commit and push the changes or paste it in your Github Repo then pull the changes, either of these two will work fine.

Travis provides the service for free but your repo in Github must be public and the free URL is different from the premium URL.

After visiting Travis, sign in with Github. Search for your Github repo then add it. Travis will go to your repo, locate the .travis.yml file and do the rest. Hopefully, if you followed every step correctly, your build should be successful and the repo should turn green with the badge at the top indicating build passing.


It’s awesome looking at that badge from your repo. So to add it to your repo, go ahead and click on it. A pop up will show with the url of the badge. Copy the url then paste it in your README file. Here’s an example of how the file should look like inside your README file.

Hooray! Your CI should now be up and running. Thanks for your time.

Happy Coding!

6 Replies to “Setting up Travis CI in Android”

  1. I have not used Travis before, but in my opinion Circle CI has an easier config file to use, and uses a Docker Images to build also. How would you compare the two in terms of ease of use and build times?

    1. What i like about Travis CI is the flexibility it gives you when configuring your build environment. Surely, running your builds in a docker container is faster than a virtual environment, but Travis allows you specify whether your builds should run in Google Compute Engine or Docker. I’m not sure if Circle Ci has the same flexibility. In terms of comparing the two, i would say it’s a matter of implementation and both tools are powerful in a unique way.

  2. I’ve worked with travis only once before Flask-python… it had to do with tests. Don’t we need some kind of tests here? or we wait for the sequel of this blog 🙂

  3. Thanks for the comments @Simiyu, @Juma. From my understanding, i stand to be corrected; the work of any build system be it travis, circle ci, jenkins is to ensure your application runs successfully without any crashes. This is irregardless of whether it has tests(unit tests or instrumentation tests). It thus helps in preventing merging changes that break your application. In order to run your tests in the build system you have to include some tasks to do that in the .yml files. Personally i use jacoco to run these tests then generate a report.

Leave a Reply

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