Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle dependencies with Travis CI on Android project

I'm having troubles building an Android project with Gradle on Travis CI.

I have declared my dependencies like this on my build.gradle:

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.0'
    compile 'com.android.support:support-v4:18.0.0'
    freeCompile files (
        'libs/GoogleAdMobAdsSdk-6.4.1.jar'
    )
}

This is my .travis.yml script:

script: 
  - TERM=dumb ./gradlew build
  - TERM=dumb ./gradlew connectedInstrumentTest

And I'm getting this on Travis:

A problem occurred configuring project ':FlavorTest'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':FlavorTest:_FreeDebugCompile'.
      > Could not find com.android.support:appcompat-v7:18.0.0.
        Required by:
            cloaked-octo-spice:FlavorTest:unspecified
      > Could not find com.android.support:support-v4:18.0.0.
        Required by:
            cloaked-octo-spice:FlavorTest:unspecified

On my local project all seems to work fine. I need to do something else in order to get the dependencies on Travis?

Thanks for the help in advance.

like image 469
UnsafePointer Avatar asked Sep 09 '13 18:09

UnsafePointer


3 Answers

I got this solved with some help. It seems that Gradle couldn't find the Android Support dependencies on the local repository, those needed to be installed with the following command:

android update sdk --filter extra-android-support --no-ui --force > /dev/null
android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null

You can check my .travis.yml file on this public repository (https://github.com/Ruenzuo/cloaked-octo-cyril), hope this helps someone else.

like image 183
UnsafePointer Avatar answered Oct 24 '22 09:10

UnsafePointer


An easier way:

android:
  components:
    - extra-android-m2repository

You must remeber to accept the license. For example adding:

android:
  licenses:
    - android-sdk-license-.+
like image 37
Brais Gabin Avatar answered Oct 24 '22 08:10

Brais Gabin


The answer above is correct. I just thought it'd be worth posting another solution with a travis.yml example. You can find a good one at Pestrada's github site: https://github.com/pestrada/android-tdd-playground/blob/master/.travis.yml

The relevant lines are:

  # Install required components.
  # For a full list, run `android list sdk -a --extended`
  # Note that sysimg-18 downloads the ARM, x86 and MIPS images (we should optimize this).
  # Other relevant API's

  - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
  - echo yes | android update sdk --filter android-18 --no-ui --force > /dev/null
  - echo yes | android update sdk --filter android-19 --no-ui --force > /dev/null
  - echo yes | android update sdk --filter sysimg-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
like image 1
loeschg Avatar answered Oct 24 '22 08:10

loeschg