Building an Android Project (beta)
Warning
The features described here are still in development and are subject to change without backward compatibility or migration support.
What This Guide Covers
This guide covers build environment and configuration topics specific to Android projects. Please make sure to read our Getting Started and general build configuration guides first.
CI Environment for Android Projects
Overview
Travis CI environment provides a large set of build tools for JVM languages with multiple JDKs, Ant, Gradle, Maven, sbt and Leiningen.
By setting
language: android
in your .travis.yml
file, your project will be built in the Android environment which provides Android SDK 22.6.2 with following preinstalled components:
- platform-tools
- build-tools-19.0.3
- android-19
- sysimg-19 (ARM)
- android-18
- sysimg-18 (ARM)
- android-17
- sysimg-17 (ARM)
- android-16
- sysimg-16 (ARM)
- android-15
- sysimg-15 (ARM)
- android-10
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
How to install or update Android SDK components
In your .travis.yml
you can optionally define the SDK components to be installed and the licenses to be accepted, as illustrated in the following example:
language: android
android:
components:
- tools
- build-tools-19.0.1
- android-19
- sysimg-19
- extra-android-support
licenses:
- android-sdk-license-bcbbd656
- '.*intel.+'
The exact component names must be specified, while the licenses can also be referenced with regular expressions (using Tcl syntax as expect
command is used to automatically interact with the interactive prompts).
If no license is specified, Travis CI will only accept android-sdk-license-bcbbd656
by default:
language: android
android:
components:
- build-tools-18.1.1
- android-8
How to Create and Start an Emulator
At the moment, these steps are not supported by Travis CI Android builder.
Basically you'll need to ship a script like wait_for_emulator
and adapt your .travis.yml
in order to make the emulator available for your tests.
Dependency Management
Travis CI Android builder assumes that your project is built with a JVM build tool like Maven or Gradle that will automatically pull down project dependencies before running tests without any effort on your side.
If your project is built with Ant or any other build tool that does not automatically handle dependences, you need to specify the exact command to run using install:
key in your .travis.yml
, for example:
language: android
install: ant deps
Default Test Command for Maven
If your project has pom.xml
file in the repository root but no build.gradle
, Maven 3 will be used to build it. By default it will use
mvn install -B
to run your test suite. This can be overridden as described in the general build configuration guide.
Default Test Command for Gradle
If your project has build.gradle
file in the repository root, Gradle will be used to build it. By default it will use
gradle build connectedCheck
to run your test suite. If your project also includes the gradlew
wrapper script in the repository root, Travis Android builder will try to use it instead. The default command will become:
./gradlew build connectedCheck
This can be overridden as described in the general build configuration guide.
Default Test Command
If Travis CI could not detect Maven or Gradle files, Travis CI Android builder will try to use Ant to build your project. By default it will use
ant debug installt test
to run your test suite. This can be overridden as described in the general build configuration guide.
Testing Against Multiple JDKs
As for any JVM language, it is also possible to test against multiple JDKs.
Build Matrix
For Android projects, env
and jdk
can be given as arrays to construct a build matrix.
Examples
- roboguice/roboguice (Google Guice on Android)
- ruboto/ruboto (A platform for developing apps using JRuby on Android)
- RxJava in Android Example Project
- Gradle Example Project (the wait for the emulator must be fixed)
- Maven Example Project (still using
language: java
, see pending pull request)