Build an Android Project
- CI Environment for Android Projects
- Sample Configuration for API Level 30+
- Installing Android SDK Components
- Dealing with Licenses
- Pre-installed Components
extras;google;google_play_services
- Creating and Starting an Emulator
- Dependency Management
- Default Test Commands
- Caching
- Testing Against Multiple JDKs
- Build Matrix
- Building on Different Environments
- Examples
- Build Config Reference
This guide covers the build environment and configuration topics specific to Android projects targeting API level 30 and above. Please review our Onboarding and General Build Configuration guides before proceeding.
r />Note: Android builds are not available on macOS environments.
CI Environment for Android Projects #
Android builds are supported on our Bionic, Focal, and Jammy build environments. Specify one of these in your .travis.yml
:
Travis CI provides a full suite of tools for JVM-based projects, including multiple JDKs, Ant, Gradle, Maven, sbt, and Leiningen.
r />Sample Configuration for API Level 30+ #
Below is an example .travis.yml
configured for Android projects targeting API level 30 and above. Notice that only the required extras (listed later) are included:
Installing Android SDK Components #
In your .travis.yml
, specify the exact SDK components to install:
r />Tip: Run
sdkmanager --list
on your local machine to view all available components and their exact names.
Dealing with Licenses #
Travis CI accepts requested licenses by default. To explicitly whitelist licenses, add the licenses
key:
Licenses can also be referenced using regular expressions.
r />Pre-installed Components #
The following components are pre-installed in the Travis CI Android build environments. However, for stable builds, explicitly list all required components:
tools
platform-tools
build-tools;30.0.0
platforms;android-30
extras;android;m2repository
extras;google;m2repository
-
extras;google;google_play_services
#
Creating and Starting an Emulator #
If your tests require an emulator, use avdmanager
to create an AVD and start the emulator:
Adjust sleep durations as necessary.
r />Dependency Management #
Travis CI assumes that your project uses a JVM build tool (e.g., Gradle, Maven) that automatically manages dependencies.
For projects using Ant or other tools, specify your dependency command:
Default Test Commands #
Maven Projects #
If your repository contains a pom.xml
(and no build.gradle
), Maven 3 is used with:
Gradle Projects #
For repositories with a build.gradle
file, Travis runs:
If a Gradle wrapper (gradlew
) exists, it uses:
Ant Projects #
If neither Maven nor Gradle files are found, Travis defaults to:
Override these defaults using our General Build Configuration guide if needed.
r />Caching #
To optimize builds and avoid uploading cache after every build, add:
Testing Against Multiple JDKs #
You can test against multiple JDKs as described in our Testing Against Multiple JDKs guide.
r />Build Matrix #
For Android projects, you can create a build matrix by providing arrays for both env
and jdk
.
Building on Different Environments #
Android projects are supported on dist: bionic
, dist: focal
, and dist: jammy
. To build on a different environment, install the necessary packages and tools. For example:
Examples #
Here are some example projects that use Travis CI with Android:
- roboguice/roboguice
- ruboto/ruboto
- RxJava Android Example Project
- Gradle Example Project
- Maven Example Project
- Ionic Cordova Example Project
Build Config Reference #
For more details, see the Travis CI Build Config Reference for Android.