Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android build variants on travis.ci

I currently have an Android project using gradle and integrated with travis.ci which has different productFlavors and buildTypes. When the "connectedCheck" task is then executed on travis.ci, it tries to package all build variants (all combinations of flavors and types). Some of them fail as the release builds need password input which I can't automate at the moment. Is there a way to tell travis.ci to build and test only a certain build variant of an Android project?

like image 517
Micky Avatar asked Jul 04 '14 12:07

Micky


People also ask

Where is build variants in Android Studio?

By default, Android Studio builds the debug version of your app, which is intended for use only during development, when you click Run. To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar.

What is a build type in Gradle in android?

Build types define certain properties that Gradle uses when building and packaging your app, and are typically configured for different stages of your development lifecycle. There are two build types defined by default, debug and release , and you can customize them and create additional build types.

What are build variants in android?

Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.


2 Answers

Say you only want to run the product flavor Trial and the build type Debug.

Instead of running ./gradlew assemble connectedCheck, which is similar to what you're doing, run this instead:

./gradlew assembleTrialDebug connectedCheckTrialDebug
like image 190
espinchi Avatar answered Oct 06 '22 22:10

espinchi


So here's how I made it work: Run a connectedAndroidTest<productFlavor><buildType> task instead of connectedCheck. Also set the assemble task in the install section of the .travis.yml:

install: - TERM=dumb ./gradlew -s assemble<productFlavor><buildType>
like image 42
Micky Avatar answered Oct 06 '22 22:10

Micky