简体   繁体   English

无法使用Travis-CI和Android构建项目

[英]Can't build project with Travis-CI and Android

I've been trying for the past 2 days build a CI with travis and android. 在过去的两天里,我一直在尝试使用travis和android构建CI。

The problem is, whatever i fix a problem, another comes up 问题是,无论我如何解决问题,都会出现另一个问题

I search in stack for the anwser, but none fix my problem 我在堆栈中搜索anwser,但没有一个能解决我的问题

You have not accepted the license agreements of the following SDK components: [com.android.support.constraint:constraint-layout:1.0.0-alpha4, com.android.support.constraint:constraint-layout-solver:1.0.0-alpha4]. 您尚未接受以下SDK组件的许可协议:[com.android.support.constraint:constraint-layout:1.0.0-alpha4,com.android.support.constraint:constraint-layout-solver:1.0.0- alpha4]。

My root build.gradle: 我的根build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0-beta1'

        //Dagger 2 dependency
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        //Realm Dependecies
        classpath "io.realm:realm-gradle-plugin:1.1.1"
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app build.gradle 应用程序build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

//Realm Dependecies
apply plugin: 'realm-android'

android {
    signingConfigs {
    }
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    dataBinding {
        enabled = true
    }

    defaultConfig {
        applicationId "rhcloud.com.financialcontrol"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    androidTestCompile('com.android.support.test:runner:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile('com.android.support.test:rules:0.5', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'

    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'


    //Dagger 2 dependencies
    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'
    provided 'javax.annotation:jsr250-api:1.0'

    compile 'klauswk:DroidUtils:0.1-ALPHA'

}

.travis.yml .travis.yml

    android: 
  components: 
    - tools
    - platform-tools
    - build-tools-24.0.1
    - android-24
    - extra-android-m2repository
    - extra-android-support
    - sys-img-armeabi-v7a-android-22
    - extra-google-google_play_services
  licenses: 
    - android-sdk-preview-license-52d11cd2
    - android-sdk-license-.+
    - google-gdk-license-.+
before-script: 
  - "android update sdk --no-ui --filter build-tools-24.0.1,android-24,extra-android-m2repository"
  - "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 &"
before_cache: 
  - "rm -f $HOME/.gradle/caches/modules-2/modules-2.lock"
before_install: 
  - "chmod +x gradlew"
cache: 
  directories: 
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/
env: 
  matrix: 
    - "ANDROID_TARGET=android-22  ANDROID_ABI=armeabi-v7a"
jdk: oraclejdk8
language: android
script: 
  - "./gradlew build connectedCheck --stacktrace"

Any help would be appreciate, the source code can be find here 任何帮助将不胜感激,源代码可以在这里找到

EDITED 已编辑

I finally manage to make it work. 我终于设法使它起作用。

First, to fix the license problem, i downgrade the buildtools and compile down to 23, and added 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' as dependency. 首先,要解决许可证问题,我将构建工具降级并编译为23,然后添加了'com.android.support.constraint:constraint-layout:1.0.0-alpha1'作为依赖项。

Also, by the anwser of Ardock, i manage to find a error in my travis.yml. 另外,通过Ardock的解决方案,我设法在travis.yml中发现错误。

Finally, i added the android-sdk-license-c81a61d9 to automatic accept the license. 最后,我添加了android-sdk-license-c81a61d9以自动接受许可证。

The working commit can be find here 工作提交可以在这里找到

Edited: 编辑:

Replace before-script: by before_script: before_script:替换before-script: before_script:

This block is not executed otherwise. 否则不执行该块。

Previous response: 先前的回应:

See this line 看到这条线

Skipping 'ARM EABI v7a System Image, Android API 22, revision 1'; 跳过“ ARM EABI v7a系统映像,Android API 22,修订版1”; it depends on 'SDK Platform Android 5.1.1, API 22, revision 2' which was not installed. 它取决于未安装的“ SDK平台Android 5.1.1,API 22,修订版2”。

Seems you already solved the license issue but you need to install the android-22 platform. 似乎您已经解决了许可问题,但是您需要安装android-22平台。

android: 
  components: 
    - tools
    - ...
    - android-22
    - sys-img-armeabi-v7a-android-22
    - ...

Or an image for android-23 to solve: 或图像为android-23解决:

com.android.builder.testing.api.DeviceException: No connected devices! com.android.builder.testing.api.DeviceException:没有连接的设备!

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

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