I've read through com.android.builder.testing.ConnectedDevice > hasTests[test(AVD) - 5.0] FAILED and I am having a very similar problem. Unfortunately, it's very difficult to discern what the actual solution to that problem was, given all of the discussion the solution author gave.
Essentially, I have the following .travis.yml file:
language: android
android:
components:
- build-tools-21.1.0
- android-19
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
- addon-google_apis-google-21
- sys-img-armeabi-v7a-android-19
before_script:
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- cat `which android-wait-for-emulator`
- android-wait-for-emulator
- adb shell input keyevent 82 &
script: ./gradlew clean build connectedCheck
When I push, and travis builds the appropriate .apk, I end up with the following log: http://pastebin.com/LVw5rG58
If I run ./gradlew clean build installDebug
, the build turns out fine, so it doesn't appear to be an issue with the timeout being too short in the android-wait-for-emulator
script (also, it's using the newer version, I've checked - see the cat which android-wait-for-emulator
command in the .travis.yml.
Additionally, I do have a single test in my source repository, and running ./gradlew clean build connectedCheck
on my local development machine (with a phone attached) works fine.
This just started happening since I updated gradle to 2.2.1 and updated the build tools to 21.1.0. However, I have another project using the exact same .travis.yml that isn't failing for some reason.
Edit:
My application has the following directory structure:
wagebase-android/
- WageBase/
- src/
- androidTest/
- java/
- com.thisclicks.wagebase/ <- Test Sources
- main/
- java/
- com.thisclicks.wagebase/ <- App sources
Edit:
It appears that if I run this on a local emulator, it also fails with the same error. I used the same configuration as in Travis, i.e.:
$ echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
$ emulator -avd test -no-skin -no-audio -no-window &
$ adb wait-for-device
$ ./gradlew connectedCheck