Klaus Klein Klaus Klein - 3 months ago 451
Android Question

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.

The problem is, whatever i fix a problem, another comes up

I search in stack for the anwser, but none fix my problem


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].


My root 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

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"


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.

Also, by the anwser of Ardock, i manage to find a error in my travis.yml.

Finally, i added the
android-sdk-license-c81a61d9
to automatic accept the license.

The working commit can be find here

Answer

Edited:

Replace before-script: by before_script:

This block is not executed otherwise.

Previous response:

See this line

Skipping 'ARM EABI v7a System Image, Android API 22, revision 1'; it depends on 'SDK Platform Android 5.1.1, API 22, revision 2' which was not installed.

Seems you already solved the license issue but you need to install the android-22 platform.

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

Or an image for android-23 to solve:

com.android.builder.testing.api.DeviceException: No connected devices!