【问题标题】:Can't build project with Travis-CI and Android无法使用 Travis-CI 和 Android 构建项目
【发布时间】:2016-12-16 09:19:38
【问题描述】:

过去 2 天我一直在尝试使用 travis 和 android 构建一个 CI。

问题是,无论我解决了什么问题,都会出现另一个问题

我在堆栈中搜索 anwser,但没有解决我的问题

您尚未接受以下 SDK 组件的许可协议: [com.android.support.constraint:constraint-layout:1.0.0-alpha4, com.android.support.constraint:constraint-layout-solver:1.0.0-alpha4]。

我的根 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
}

应用构建.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

    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"

任何帮助将不胜感激,源代码可以找到here

已编辑

我终于成功了。

首先,为了解决许可问题,我将 buildtools 降级并编译到 23,并添加 'com.android.support.constraint:constraint-layout:1.0.0-alpha1' 作为依赖项。

另外,通过 Ardock 的 anwser,我设法在我的 travis.yml 中找到了一个错误。

最后,我添加了android-sdk-license-c81a61d9 以自动接受许可证。

工作提交可以找到here

【问题讨论】:

  • 你需要在更新你的android时接受许可协议(即你之前的脚本块中的android更新命令)

标签: android github continuous-integration travis-ci


【解决方案1】:

已编辑:

before-script: 替换为before_script:

否则不会执行此块。

之前的回复:

this line

跳过“ARM EABI v7a 系统映像,Android API 22,修订版 1”;它 取决于“SDK 平台 Android 5.1.1,API 22,修订版 2”,它是 未安装。

看来您已经解决了许可问题,但您需要安装 android-22 平台。

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

或者一张图让android-23解决:

com.android.builder.testing.api.DeviceException:没有连接设备!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-10
    • 2012-11-09
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多