How to configure Travis-CI for Android library?

I am developing an Android library ( RateMyApp , which you can find on GitHub), but I don’t see how I can configure Travis CI to create it every time I click on a new code.

I am using the following .travis.yml file:

 language: java script: - gradle bundleRelease 

but it seems to be ignored since gradle bundleRelease never called. Instead, I get the following output, which tells me that instead of gradle assemble is called.

 Using worker: worker-linux-8-1.bb.travis-ci.org:travis-linux-5 travis_fold:start:git.1 $ git clone --depth=50 --branch=master git://github.com/mariosangiorgio/RateMyApp.git [...] mariosangiorgio/RateMyApp Cloning into 'mariosangiorgio/RateMyApp'... done. travis_fold:end:git.1 $ cd mariosangiorgio/RateMyApp travis_fold:start:git.3 $ git checkout -qf 90faf4539c835136895ea92dd2bcc7da12ad1145 travis_fold:end:git.3 $ java -version java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode) $ javac -version javac 1.7.0_45 travis_fold:start:install $ gradle assemble [...] The command "gradle assemble" failed and exited with 1 during install. Your build has been stopped. 

I read the page related to the documentation , but unfortunately it was not very useful to me.

+6
source share
3 answers

Here is my yaml file that builds apk. But it should work for the library.

 language: java jdk: oraclejdk7 branches: only: - master before_install: - chmod +x gradlew # Install base Android SDK - sudo apt-get update -qq - if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch > /dev/null; fi - wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz - tar xzf android-sdk_r22.0.5-linux.tgz - export ANDROID_HOME=$PWD/android-sdk-linux - export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools # install android build tools - wget https://dl-ssl.google.com/android/repository/build-tools_r19.0.1-linux.zip - unzip build-tools_r19.0.1-linux.zip -d $ANDROID_HOME - mkdir -p $ANDROID_HOME/build-tools/ - mv $ANDROID_HOME/android-4.4.2 $ANDROID_HOME/build-tools/19.0.1 # Install required components. - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null - echo yes | android update sdk --filter android-19 --no-ui --force > /dev/null - echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null install: - true script: - TERM=dumb ./gradlew test assembleDebug 

But be careful, as this script does not push the inline artifact anywhere

+3
source

I am using the SDK installer script in .travis.yml for Hilt .

 language: java jdk: oraclejdk7 before_install: # Install base Android SDK and components - sudo apt-get update -qq - sudo apt-get install -qq libstdc++6:i386 lib32z1 expect - export COMPONENTS=build-tools-19.0.3,android-19,extra-android-support,extra-android-m2repository,extra-google-m2repository - export LICENSES=android-sdk-license-bcbbd656 - curl -3L https://raw.github.com/embarkmobile/android-sdk-installer/version-2/android-sdk-installer | bash /dev/stdin --install=$COMPONENTS --accept=$LICENSES - source ~/.android-sdk-installer/env install: # Without TERM=dumb, we get mangled output in the Travis console - TERM=dumb ./gradlew clean assemble -PdisablePreDex script: - TERM=dumb ./gradlew check -PdisablePreDex 

EDIT: Travis-CI introduced Android as a first-class citizen - http://blog.travis-ci.com/2014-05-07-android-build-support-now-in-beta/

+3
source

To find out why you see gradle assemble instead of gradle bundleRelease :

gradle assemble is called by default at the install: Travis step (see Travis docs for a description of the steps and this note ).

Since you do not have the install: section of your script to override the default value, Travis calls gradle assemble .

This can be prevented by adding the following lines in which Travis does nothing during the installation phase:

 install: - true 

I had a similar problem , with Travis gradle assemble when I wanted to execute gradlew assembleDebug .

So, for me, the full script works (as of May 1, 2014 with Android as a first class citizen ):

 language: android jdk: oraclejdk7 android: components: - build-tools-19.0.1 install: - true script: TERM=dumb ./gradlew assembleDebug 

Thanks to Austyn Mahoney for clarifying this for me here .

EDIT

As of May 8, 2014, Travis CI has removed the default install: stage for Android beta, as discussed here . So now you can remove the install: step from your script, and Travis should not execute gradle assemble .

+1
source

All Articles