Setting up Travis CI


Travis is a continuous integration service that enables you to run tests against your latest Android builds. You can setup your projects to run both unit and integration tests, which can also include launching an emulator.

Signing Up

Login to Travis CI and sign-in with your GitHub credentials. You will need to grant access to any repositories that will be used. If you are using a private repository and don't intend for the source code to be shared, you will need to signup for a paid subscription plan.


You simply need to create a .travis.yml file in the root directory. The simplest configuration to install the Build Tools and Android SDK 24. You can launch the Gradle wrapper to build and run emulator tests. Make sure the tools line is first to ensure that Build Tools (esp for versions above API 24). It also needs to be included twice.

language: android
    - tools # to get the new `repository-11.xml`
    - tools # see
    - platform-tools
    - build-tools-27.0.3
    - android-27
  - yes | sdkmanager "platforms;android-27"
   - ./gradlew build connectedCheck

See the docs here for more information. By default, all SDK license agreements are accepted but you can also dictate which ones to accept.

Design Support Library

If you are intending to use the new Design Support Library, you will need to make sure to include the Maven repo in your root build.gradle file:

repositories {
    maven {
        url ''

Because of this change announced in Google I/O 2017, the use of extra-android-m2repository in travis.yml is no longer needed:

language: android

     - extra-android-m2repository

Google Play Services

If you intend to use Google Play Services with Travis, make sure you also use the Maven support library.

Lambda expressions support

To add support for lambda expressions, make sure to specify JDK 8 or higher:

  - oraclejdk8


If you see an error code 137, chances are that the Travis build has ran out of memory trying to load all your dependencies. org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 137

Here are a few ways to try to resolve:

  • If you are using Google Play Services, try to be more selective about the modules you import. In prior versions before 6.5, you had to include all packages which often caused the 65K method limit to be reached. If you only wish to use the Google Cloud Messaging package and not Google Fitness or Google Wear, you do not need to import Instead, you can simply specify the libraries explicitly:
implementation ''
  • If you are still having issues, you will likely need to disable predexing, which compiles each dependency individually into Android bytecode and turns each module into a .dex file. The problem is that this process is more memory intensive and takes longer and provides benefits only when doing incremental builds. See this section for more information.

To disable pre-dexing, add this line to your root build.gradle to detect whether Travis is currently running:

ext {
    travisBuild = System.getenv("TRAVIS") == "true"
    // allows for -Dpre-dex=false to be set
    preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))

Then add this line to your app/build.gradle:

android {
  dexOptions {
     // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
     preDexLibraries = preDexEnabled && !travisBuild
  • Disable container-based builds, which currently only have a maximum of 4GB of memory, whereas standard versions have a max of 7.5GB of memory (according to this doc):
sudo: required
  • If you want to print any lint error issues, add this line:
after_failure: "cat $TRAVIS_BUILD_DIR/app/build/outputs/lint-results-debug.xml"
Fork me on GitHub