简体   繁体   中英

Travis-CI Build error android app

Im trying to build my Application using Travis-CI.
But for some reason its constantly giving this error:

The command "./gradlew build connectedCheck" exited with 1.

This is what is in my .travis.yml:

    language: android
    before_install:
      - chmod +x gradlew
    android:
     components:
       - tools 
       - platform-tools
       - build-tools-27.1.1
       - android-27

    script:
     - ./gradlew build connectedCheck

Here you got a link to my Travis build:
https://travis-ci.org/Luuk2016/WeatherApp-Android/jobs/371162957

And my build.gradle file:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.district420.weatherapp"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Hopefully someone can help me

Your build fails because you have not accepted licenses for Android SDK packages. Add this line to your travis.yml.

licenses:
  - '.+'

EDIT :

Since your build now fails due to the error "No connected device". You must create an emulator in the travis and run the instrumentation tests on it. Add these lines too in the travis.yml file.

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

Add these lines to the components section of the travis file.

 - android-$ANDROID_EMULATOR_LEVEL
 - sys-img-armeabi-v7a-google_apis-$ANDROID_EMULATOR_LEVEL

Add these line too

before_script:
# Create and start emulator.
  - 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 &

Also, add this as the first line of travis.yml

sudo: false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM