Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Travis CI for Android

Trying to get started with Travis CI for my Android projects. First I set up dummy project with Android Bootstrap, and added a the yml file from square's otto project - modified to have my username and repo name.

My build fails with the error "/home/travis/build.sh: line 94: android: command not found, even when square's project builds fine.

The error seems to indicate that the path isn't set properly, in spite of having these lines in my .travis.yml

  • export ANDROID_HOME=~/builds/f2prateek/FoodBot/android-sdk-linux
  • export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools

Is there something else I need to be setting up to get this right?

like image 558
f2prateek Avatar asked Jan 17 '13 01:01

f2prateek


2 Answers

Update 2014/05: Travis CI now has official support for Android.

http://docs.travis-ci.com/user/languages/android/

The workarounds below are not required anymore, unless you want to use it on a non-Android VM.


The issue is most likely with the fact that Travis CI switched over to 64-bit virtual machines. You need to install ia32-libs for Android to run in a 64-bit environment. This can currently be achieved with:

sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch

I wrote a blog post on getting Android builds running on Travis, which covers this as well as other details: http://rkistner.github.com/android/2013/02/05/android-builds-on-travis-ci/

Travis might support Android-specific virtual machines in the future, which will simplify the configuration. Follow the conversation on issue #56 for updates on this issue and discussions on the Android-specific VM.

like image 92
Ralf Avatar answered Oct 22 '22 08:10

Ralf


This reply covers up to Travis automatic testing. See the Medium article for the complete version: automatic testing and deployment.


Travis CI (@ API 26+)

Apparently from API 24 setting up the emulator is a pain on Travis is a pain[1][2][3][4].

Sean Barbeau, who's been digging through this for a lot more time than I have, has pretty much considered it impossible to emulate.

But there is a working and simpler alternative for API 26+, which is running the tests with gradlew instead of the adb emulator. It seems to have some limitations, but it should work. Credits to PocketHub.

sudo: required

language: android
jdk: oraclejdk8

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -rf $HOME/.gradle/caches/*/plugin-resolution/

cache:
  directories:
  - $HOME/.gradle/caches/
  - $HOME/.gradle/wrapper/
  - $HOME/.android/build-cache

env:
 global:
 - ANDROID_API=26
 - ANDROID_BUILD_TOOLS=26.0.2

android:
  components:
  - tools
  - tools # Running this twice get's the latest build tools (https://github.com/codepath/android_guides/wiki/Setting-up-Travis-CI)
  - platform-tools
  - android-${ANDROID_API}
  - build-tools-${ANDROID_BUILD_TOOLS}
  - extra

script:
- ./gradlew clean test build

Environment variables that you might have to adapt to your project ones:

Some information should be available either in the build.gradle or AndroidStudio -> Settings -> Android SDK -> SDK Tools

(if you're building a new project with an updated AndroidStudio you should just pick the latest versions in the following links)

ANDROID_API: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels

ANDROID_BUILD_TOOLS: https://developer.android.com/studio/releases/build-tools.html

Example .travis.yml setup (with autodeploy to GitHub releases).

like image 3
zurfyx Avatar answered Oct 22 '22 09:10

zurfyx