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. I recently added Travis Continuous Integration Connfa, Giggity and Giraffe app. In this blog, I describe how to set up Travis Continuous Integration in an Android Project with reference to Giggity app.
- Use your GitHub account, sign in to either to Travis CI .org for public repositories or Travis CI .com for private repositories
- Accept the GitHub access permissions confirmation.
- Once you’re signed in to Travis CI, and synchronized your GitHub repositories, go to your profile page and enable the repository you want to build:
- Now you need to add a .travis.yml file into the root of your project. This file will tell how Travis handles the builds. You should check your .travis file on Travis Web Lint before committing any changes to it.
- You can find the very basic instructions for building an Android project from the Travis documentation. But here we specify the .travis.yml build accordingly for Giggity’s continuous integration. Here, language shows that it is an Android project. We write “language: ruby” if it is a ruby project. If you need a more customizable environment running in a virtual machine, use the Sudo Enabled infrastructure. Similarly, we define the API, play services and libraries defined as shown.
language: android sudo: required jdk: - oraclejdk8 # Use the Travis Container-Based Infrastructure android: components: - platform-tools - tools - build-tools-25.0.3 - android-25 # For Google APIs - addon-google_apis-google-$ANDROID_API_LEVEL # Google Play Services - extra-google-google_play_services # Support library - extra-android-support # Latest artifacts in local repository - extra-google-m2repository - extra-android-m2repository - android-sdk-license-.+ - '.+' before_script: - chmod +x gradlew script: - ./gradlew build
Now when you make a commit or pull request Travis check if all the defines checks pass and it is able to be merged. To be more advanced you can also define if you want to build APKs too with every build.
- Travis Continuous Integration Documentation – https://docs.travis-ci.com/user/getting-started/