Continuous Integration with Maven and Travis for Android

In order to run your android unit tests automatically on external virtual server after each git commit you need a continuous integration system. There are a couple of good services e.g. jenkins and travis out there. But how do you use them? Here is one way for travis. You can start off by forking android-maven-example and adapt it to your own project. Maven’s package manager ability let’s you download and install all dependency packages. In example you also have several maven goals pre-defined. Most important ones are install – installing to a device or emulator, package – creating a jar of your libs and clean.

Now the automated tests are setup and you only need to make an account on and turn on all the repositories which you want to let test.

The android maven example travis file is a bit outdated however. Android has been added as a first class citizen. So your travis.yml file could look like this:

To run the maven tests locally you can also create an emulator and run the maven goal. Note: On MAC you can also install travis-build to simply run everything by using travis run.

Create the emulator named test with e.g. API 10 and armeabi cpu.

Start the emulator. Note: No window required for first tests, if you want to tests the ui you might want to remove the -no-window parameter.

Run the test goal. Note: -e -X for showing errors and warnings in the console.

See also Travis CI for iOS.

Facebook comments:


1 Comment

  1. Have you tried using Travis to run end-to-end tests on Android? I am using Robotium to run tests, and it is working locally, but on Travis, it is failing sometimes to find UI controls.

Leave a Reply