I am developing an Android library (RateMyApp, which you can find on GitHub) but I can't see how I should setup Travis CI to build it every time I push new code.
The .travis.yml
file I am using is the following:
language: java
script:
- gradle bundleRelease
but it seems to be ignored because gradle bundleRelease
is never invoked. Instead I get the following output that suggests me that gradle assemble
is invoked instead.
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 linked in the documentation but unfortunately it wasn't much helpful to me.
Configuration. Travis CI is configured by adding a file named . travis. yml , which is a YAML format text file, to the root directory of the repository.
GitHub projects can be synced with Travis CI. It can perform auto deployments on passing the builds. It will be able to deploy on multiple cloud services.
The first job is to build the image and the second job is going to be to run the NPM test target.
Here is mine yaml
file which is building apk. But it should work also for 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 since this script doesn't push built artefact anywhere
I use an SDK installer script in the .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 has implemented Android as a first class citizen - http://blog.travis-ci.com/2014-05-07-android-build-support-now-in-beta/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With