简体   繁体   English

Travis-CI Build error android app

[英]Travis-CI Build error android app

Im trying to build my Application using Travis-CI. 我正在尝试使用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: 这是我的.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: 在这里,您可以链接到我的Travis版本:
https://travis-ci.org/Luuk2016/WeatherApp-Android/jobs/371162957 https://travis-ci.org/Luuk2016/WeatherApp-Android/jobs/371162957

And my build.gradle file: 和我的build.gradle文件:

    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. 由于您尚未接受Android SDK软件包的许可证,因此构建失败。 Add this line to your travis.yml. 将此行添加到您的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. 您必须在travis中创建一个仿真器并在其上运行检测测试。 Add these lines too in the travis.yml file. 在travis.yml文件中也添加这些行。

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. 将这些行添加到travis文件的components部分。

 - 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 另外,将其添加为travis.yml的第一行

sudo: false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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