Config travis.yml file in android project error - android

i just want travis ci check my project not have error (i don't have test case). But when i commit my code,travis ci always run fail or error (my project not have error). Someone can help me.
My travis.yml file content:
language: android
android:
components:
- build-tools-23.0.2
- android-23
- extra
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_script:
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script: ./gradlew connectedAndroidTest
Chmod:
Output:

Related

How to know the exact error from Travis build

Currently, I am facing a travis CI build error in my repository here, and I'd really like to know the exact issue as connectedCheck only outputs
Tests on test(AVD) - 5.1.1 failed: Instrumentation run failed due to 'java.lang.NullPointerException'
in Travis, and the tests are passing just fine in my own machine.
This is my current .travis.yml :
sudo: required
language: android
jdk: oraclejdk8
env:
global:
- ANDROID_TARGET=android-22
- ANDROID_ABI=armeabi-v7a
android:
components:
- tools
- platform-tools
- build-tools-27.0.3
- android-27
- android-22
- extra-android-m2repository
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_script:
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
- ./build.sh
- ./gradlew connectedCheck coveralls
on:
tags: true
I want to know how to get a more detailed error message (e.g. line number).
Well, it's right there in logs, according to travis job, here's the test which is failing test_shouldConvertMonthsToYears due to java.lang.NullPointerException.
Hope it helps.

Travis CI cant find our gradlew file

We are trying to integrate our android app with travis CI. But it always fails with cannot access ‘gradlew’: No such file or directory. We can run the gradlew script from our local computer and the file is tracked by git. What can the problem be?
Our .travis.yml file:
sudo: false
language: android
jdk: oraclejdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
before_script:
- cd TreasurePleasure
- echo no | android create avd --force -n test -t "android-"$ANDROID_EMULATOR_LEVEL --abi $ANDROID_ABI --tag $ANDROID_TAG
- emulator -avd test -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
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
- build-tools-27.0.3
- android-27
- android-$ANDROID_EMULATOR_LEVEL
- sys-img-armeabi-v7a-google_apis-$ANDROID_EMULATOR_LEVEL
licenses:
- '.+'
env:
global:
- ANDROID_API_LEVEL=27
- ANDROID_EMULATOR_LEVEL=21
- ANDROID_BUILD_TOOLS_VERSION=27.0.3
- ANDROID_ABI=armeabi-v7a
- ANDROID_TAG=google_apis
- ADB_INSTALL_TIMEOUT=20
before_install:
- chmod +x gradlew
- yes | sdkmanager "platforms;android-27"
script:
- "./gradlew clean build connectedCheck -PdisablePreDex --stacktrace"
# run tests against the emulator
- ./gradlew connectedAndroidTest
# run tests against the JVM
- ./gradlew test
Most of this is copy paste since this is the first project for us that are using Travis CI.
Our error:
This is how it works in my scripts:
before_script:
- cd ${TRAVIS_BUILD_DIR}/TreasurePleasure
- chmod +x ./gradlew
script: "./gradlew assemble"

Test espresso with Travis

I am trying to test integration tests with Travis-CI. I have the yml:
language: android
jdk: oraclejdk8
sudo: false
android:
components:
- platform-tools
- tools
- build-tools-25.0.2
- android-25
- sys-img-armeabi-v7a-android-22
#Extras
- extra-android-m2repository
- extra-google-m2repository
- extra-android-m2repository
before_script:
- android list targets
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew test
- ./gradlew connectedAndroidTest
script: "./travis-build.sh"
This should work, but I am always getting:
Error: Target id is not valid. Use 'android list targets' to get the target ids.
I have no idea how to fix this problem...
Any help is appreciated
Old VM (used with sudo: false) only include platforms up to android-21, please try this
language: android
jdk: oraclejdk8
sudo: false
android:
components:
- platform-tools
- tools
- build-tools-25.0.2
- android-22 # Android platform used by your alternative emulator
- android-25
- sys-img-armeabi-v7a-android-22
#Extras
- extra-android-m2repository
- extra-google-m2repository # Removed duplicated component
before_script:
- android list targets
- echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew test
- ./gradlew connectedAndroidTest
script: "./travis-build.sh"

Android Espresso tests on Travis-CI

I currently have problems running Espresso tests on Travis-CI due to NoMatchingViewException, while running them locally works fine.
It doesnt seem like my .travis.yml has any problems, cause I've checked some other repositories with travis+espresso and it's quite similar.
language: android
jdk: oraclejdk8
sudo: false
env:
global:
- ANDROID_TARGET=android-19
- ANDROID_ABI=armeabi-v7a
android:
components:
# Update Android SDK Tools
- tools
- platform-tools
- build-tools-23.0.3
- android-23
# Support library
- extra-android-support
- extra-google-google_play_services
- extra-android-m2repository
- extra-google-m2repository
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
before_script:
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
script:
- ./gradlew connectedAndroidTest jacocoTestReport
after_success:
- bash <(curl -s https://codecov.io/bash)
In my tests I just make calls like this, and everything is fine
onView(withId(R.id.email_edittext)).check(matches(hasErrorText(text)))
But on Travis-CI I still got failed tests
com.tests.LoginTest > test_invalidPassword[test(AVD) - 4.4.4] FAILED
android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: mob.prokky.gameshare:id/email_edittext
Full Travis-CI log available here while the full tests are on github
I posted the issue in the travis git account
It looks like issue with creating emulator for the tests

Travis CI Build Fails for android-20 and android-22

I want to test my code from android-15 to android-23, but unfortunately build fails for android-20 and android-22.
Error: Invalid --tag default for the selected target.
The command "echo no | android create avd --force -n test -t
$ANDROID_TARGET --abi $ANDROID_ABI" failed and exited with 1 during .
travis file :
language: android
sudo: false
jdk: oraclejdk7
os:
- linux
android:
components:
- platform-tools
- tools
- build-tools-23.0.3
- android-23
# Additional components
- extra
- extra-google-m2repository
- extra-android-m2repository
- extra-android-support
# Images
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
env:
matrix:
- ANDROID_SDKS=android-15 ANDROID_TARGET=android-15 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-16 ANDROID_TARGET=android-16 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-17 ANDROID_TARGET=android-17 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-18 ANDROID_TARGET=android-18 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-19 ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-20 ANDROID_TARGET=android-20 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-21 ANDROID_TARGET=android-21 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-22 ANDROID_TARGET=android-22 ANDROID_ABI=armeabi-v7a
- ANDROID_SDKS=android-23 ANDROID_TARGET=android-23 ANDROID_ABI=armeabi-v7a
global:
# wait up to 10 minutes for adb to connect to emulator
- ADB_INSTALL_TIMEOUT=10
cache:
directories:
- $HOME/.gradle/caches/2.10
- $HOME/.gradle/caches/jars-1
- $HOME/.gradle/daemon
- $HOME/.gradle/native
- $HOME/.gradle/wrapper
before_install:
- chmod +x gradlew
before_script:
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
- emulator -avd test -no-skin -no-audio -no-window &
script:
- android-wait-for-emulator
- adb devices
- adb shell setprop dalvik.vm.dexopt-flags v=n,o=v
- adb shell input keyevent 82 &
- ./gradlew connectedCheck
travis result
How fix it?
The Android 20 SDK target is for KitKat4.4 wearables and has a slightly different system image with abi prefix that is causing the error.
Under the #images you can add the image provided by Travis-CI
- sys-img-armeabi-v7a-android-wear-20
In the android 20 matrix script you will have to add android-wear/armeabi-v7
- ANDROID_SDKS=android-20 ANDROID_TARGET=android-20 ANDROID_ABI=android-wear/armeabi-v7a

Categories

Resources