3

I guess this is travis-ci support? I was sent here from their website. I guess I should ask the question here.

So I'm adding Google Analytics to my app, and to do that I had to update gradle to version 2.10 for their plugin. After I finished it all travis-ci ran my build, but I get the following error on every build:

com.android.builder.testing.ConnectedDevice > No tests found.[test(AVD) - 5.0.2] FAILED

This wasn't an issue when I was using gradle2.2.1.-all.

To update I changed the distributionUrl in gradle/wrapper/gradle-wrapper.properties

Anyone know a fix to this? All my other branches are fine, where I did not make this change.

For reference here is my travis.yml, I didn't change anything to it, just updated gradle.

language: android
jdk: oraclejdk7
android:
  components:
    - platform-tools
    - tools
    - build-tools-23.0.2
    - android-23
    - sys-img-armeabi-v7a-android-21
    - extra-android-support
    - extra-android-m2repository
    - extra-google-m2repository
    - extra-gooogle-google_play_services

env:
  global:
    - ADB_INSTALL_TIMEOUT=8
    - MALLOC_ARENA_MAX=2

sudo: false
cache:
  directories:
    - $HOME/.gradle/caches/2.8
    - $HOME/.gradle/caches/jars-1
    - $HOME/.gradle/daemon
    - $HOME/.gradle/native
    - $HOME/.gradle/wrapper

before_install:
  - export ANDROID_HOME=/usr/local/android-sdk
  - export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
  - echo "sdk.dir=$ANDROID_HOME" > local.properties

notifications:
  slack: caketechnologies:pnmNEHM1ZxudlMZNTv6oVgcT

install:
  - TERM=dumb ./gradlew -s assembleDemoDebug

before_script:
  # Create and start emulator
  - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

script:
  - ./gradlew connectedAndroidTest -PdisablePreDex --stacktrace
RED_
  • 2,997
  • 4
  • 40
  • 59

3 Answers3

5

This is my .travis.yml file. Download gradle 2.10 before you start the build since it's not in Travis yet.

language: android
jdk:
    - oraclejdk8
env:
  matrix:
    - ANDROID_TARGET=android-21 ANDROID_ABI=armeabi-v7a
  global:
    - ADB_INSTALL_TIMEOUT=8
android:
  components:
    - build-tools-23.0.3
    - android-23
    - add-on
    - extra
    - sys-img-armeabi-v7a-android-21
before_script:
    - wget http://services.gradle.org/distributions/gradle-2.10-bin.zip
    - unzip gradle-2.10-bin.zip
    - export GRADLE_HOME=$PWD/gradle-2.10
    - export PATH=$GRADLE_HOME/bin:$PATH

Hope it helps.

Nevin Chen
  • 1,815
  • 16
  • 19
  • btw, if you use gradlew then you don't have to manually download it. Check here https://docs.gradle.org/current/userguide/gradle_wrapper.html – Nevin Chen Apr 19 '16 at 12:01
  • Adding the before script to specify the version of gradle to use really solved this. Thanks – Robert Leggett Nov 21 '16 at 00:50
0

these suggestions don't solve the issue, ignore this response

You are using android gradle plugin 1.5 but you updated yesterday google play services plugin to 2.0.0.x to support google-services.json for different productFlavors. They updated both from 1.5 to 2.0.0.x here. I would try to also update android gradle plugin to 2.0.0.x like here:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-beta6'
        classpath 'com.google.gms:google-services:2.0.0-beta6'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Last update: I'm not using this plugin version, perhaps updating gradle plugin versions to 2.0.0.X like here solves the issue.

Google just included support for flavors on version 2.0 of the play services plugin. Since this version of the gradle plugin com.google.gms:google-services:2.0.0-alpha3

And without the PATH changes on Travis-ci, I tried it one time, and they already export their default location, I'm not sure now, but it was an issue for me, and I added new location at the beginning.

Update:

Due this answer doesn't solve the issue, extra suggestions:

  • Is your local build working after adding 2.10? Google-services plugin config
  • Build ./gradlew build connectedCheck -PdisablePreDex --debug
  • Update Android Gradle plugin version
  • I suggest adding more info --debug so you can read the real reason
  • Change skin
  • Use ./gradlew clean assemble -PdisablePreDex
  • Add the new exports to the beginning of the PATH, so are found before the default

First answer:

Perhaps you need clearing-caches or change this line:

- $HOME/.gradle/caches/2.8

by

- $HOME/.gradle/caches/

I guess you should comment out the next lines to discard caching related issues:

sudo: false
cache:
  directories:
    - $HOME/.gradle/caches/2.8
    - $HOME/.gradle/caches/jars-1
    - $HOME/.gradle/daemon
    - $HOME/.gradle/native
    - $HOME/.gradle/wrapper
Community
  • 1
  • 1
albodelu
  • 7,931
  • 7
  • 41
  • 84
  • I tried this, deleted caches on travis website and commentated out the cache bit in my .yml but got the same error when running the build. – RED_ Mar 10 '16 at 12:42
  • Perhaps is the first suggestion, Gradle plugin version < 1.5 requires gradle version < 2.10, what version are you using? – albodelu Mar 10 '16 at 14:19
  • I'm using gradle version 1.5.0, just trying some of your suggestions now. – RED_ Mar 10 '16 at 14:30
  • Now I'm getting the following error when running a build using clean assemble: File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it. That's annoying because I added it to each productFlavor and it works fine. Only on travis is fails. – RED_ Mar 10 '16 at 14:35
  • Sorry, I'm not using it, perhaps another can help you, good luck, I found this http://stackoverflow.com/questions/33866061/file-google-services-json-is-missing-from-module-root-folder-the-google-service – albodelu Mar 10 '16 at 15:01
  • Thanks for trying to help, updated my gradle plugin to 2.0.0-beta6, but still getting the same error. Wish Google not force people to use google-services if it's still in beta. – RED_ Mar 10 '16 at 17:19
0

As an alternative, use gradle wrapper (aka gradlew). Travis use gradlew if available.

Chapter 5. The Gradle Wrapper

David Bernard
  • 1,560
  • 13
  • 15