Android travis-c和appcompat v-21出现错误

Android travis-c和appcompat v-21出现错误,android,travis-ci,Android,Travis Ci,我想在我的android项目中用travis CI设置CI 这些是我的毕业证书: 顶级 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenCentral() maven { url "https://oss.sonatype.org/con

我想在我的android项目中用travis CI设置CI

这些是我的毕业证书:

顶级

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        flatDir{
            dirs 'libs'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.1'
        classpath 'org.robolectric:robolectric-gradle-plugin:0.12.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}
具体项目:

apply plugin: 'com.android.application'
apply plugin: 'robolectric'
apply from: 'config/quality.gradle'

dependencies {
    compile files('libs/com.mobandme.ada_v2.4.4.jar')
    compile 'com.squareup:otto:1.3.5'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.github.pedrovgs:renderers:1.0.9'
    compile 'com.jakewharton:butterknife:5.0.1'
    compile 'com.etsy.android.grid:library:1.0.4'
    compile 'ch.acra:acra:4.5.0'
    compile 'com.loopj.android:android-async-http:1.4.6'
    compile 'com.android.support:support-v4:21.0.2'
    compile 'com.android.support:cardview-v7:21.0.2'
    compile 'com.shamanland:fab:0.0.5'
    compile 'com.github.johnkil.android-robototextview:robototextview:2.1.0'
    compile 'com.path:android-priority-jobqueue:1.1.2'
    compile "com.android.support:appcompat-v7:21.0.2"
    compile 'com.jakewharton:disklrucache:2.0.2'
    compile 'com.squareup.retrofit:retrofit:1.7.1'
    compile 'com.snappydb:snappydb-lib:0.5.0'
    compile 'com.esotericsoftware.kryo:kryo:2.24.0'

}

repositories{
    flatDir{
        dirs 'libs'
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.1'

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 21
        versionCode 113
        versionName "1.0"
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }

    signingConfigs {
        release {
            storeFile file('***')
            storePassword '***'
            keyAlias '***'
            keyPassword '***'
        }
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    productFlavors {}
}
还有我的特拉维斯档案

    language: java
    jdk: oraclejdk7
    env:
      matrix:
        - ANDROID_SDKS=android-21  ANDROID_TARGET=android-21
    branches:
      only:
        - master
    before_install:
      - chmod +x gradlew
      # Install base Android SDK
      - wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz
      - tar xzf android-sdk_r23.0.2-linux.tgz
      - export ANDROID_HOME=$PWD/android-sdk-linux
      - export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
      # install android build tools
      - wget https://dl-ssl.google.com/android/repository/build-tools_r21.1.1-linux.zip
      - unzip build-tools_r21.1.1-linux.zip -d $ANDROID_HOME
      - mkdir -p $ANDROID_HOME/build-tools/
      - mv $ANDROID_HOME/android-5.0 $ANDROID_HOME/build-tools/21.1.1
      - echo yes | android update sdk --filter build-tools-21.1.1 --no-ui --force > /dev/null
      - echo yes | android update sdk --filter tools --no-ui --force > /dev/null
      - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
      - echo yes | android update sdk --filter android-21 --no-ui --force > /dev/null
      - echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
      - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null
      - echo yes | android update sdk --filter extra-google-m2repository --no-ui --force > /dev/null
      - echo yes | android update sdk --filter extra-google-google_play_services --no-ui --force > /dev/null

    script:
      - TERM=dumb ./gradlew assembleRelease
这是特拉维斯的输出

Using worker: worker-linux-docker-e8480109.prod.travis-ci.com:travis-linux-6
system_info
Build system information
Build language: java
Installing an SSH key from: default repository key
Key fingerprint: c3:f4:e6:fd:0c:b3:83:41:2a:d8:cd:ca:b1:3e:65:ca
git.checkout
1.15s$ git clone --depth=50 --branch=master git@github.com:colymore/firext-android.git colymore/firext-android
Cloning into 'colymore/firext-android'...
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
remote: Counting objects: 2088, done.
remote: Compressing objects: 100% (909/909), done.
remote: Total 2088 (delta 1137), reused 1840 (delta 912)
Receiving objects: 100% (2088/2088), 5.69 MiB | 0 bytes/s, done.
Resolving deltas: 100% (1137/1137), done.
Checking connectivity... done.
$ cd colymore/firext-android
$ git checkout -qf 80a86aee1209b99d40d2b11d08292dba6958dbbd
This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables. See http://docs.travis-ci.com/user/workers/container-based-infrastructure/ for details.
Setting environment variables from .travis.yml
$ export ANDROID_SDKS=android-21
$ export ANDROID_TARGET=android-21
$ jdk_switcher use oraclejdk7
Switching to Oracle JDK7 (java-7-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-7-oracle
$ export TERM=dumb
$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
$ javac -version
javac 1.7.0_60
before_install.1
0.01s$ chmod +x gradlew
before_install.2
1.19s$ wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz
--2014-11-30 13:29:31--  http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz
Resolving dl.google.com (dl.google.com)... 74.125.228.97, 74.125.228.98, 74.125.228.99, ...
Connecting to dl.google.com (dl.google.com)|74.125.228.97|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 140827643 (134M) [application/x-tar]
Saving to: `android-sdk_r23.0.2-linux.tgz'
100%[======================================>] 140,827,643  118M/s   in 1.1s    
2014-11-30 13:29:33 (118 MB/s) - `android-sdk_r23.0.2-linux.tgz' saved [140827643/140827643]
before_install.3
1.37s$ tar xzf android-sdk_r23.0.2-linux.tgz
before_install.4
0.00s$ export ANDROID_HOME=$PWD/android-sdk-linux
before_install.5
0.00s$ export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
before_install.6
0.38s$ wget https://dl-ssl.google.com/android/repository/build-tools_r21.1.1-linux.zip
--2014-11-30 13:29:34--  https://dl-ssl.google.com/android/repository/build-tools_r21.1.1-linux.zip
Resolving dl-ssl.google.com (dl-ssl.google.com)... 74.125.22.136, 74.125.22.190, 74.125.22.91, ...
Connecting to dl-ssl.google.com (dl-ssl.google.com)|74.125.22.136|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 32642454 (31M) [application/zip]
Saving to: `build-tools_r21.1.1-linux.zip'
100%[======================================>] 32,642,454   109M/s   in 0.3s    
2014-11-30 13:29:34 (109 MB/s) - `build-tools_r21.1.1-linux.zip' saved [32642454/32642454]
before_install.7
0.71s$ unzip build-tools_r21.1.1-linux.zip -d $ANDROID_HOME
Archive:  build-tools_r21.1.1-linux.zip
   creating: /home/travis/build/colymore/firext-android/android-sdk-linux/android-5.0/
  inflating: /home/travis/build/colymore/firext-android/android-sdk-linux/android-5.0/NOTICE.txt  

before_install.8
0.01s$ mkdir -p $ANDROID_HOME/build-tools/
before_install.9
0.01s$ mv $ANDROID_HOME/android-5.0 $ANDROID_HOME/build-tools/21.1.1
before_install.10
3.17s$ echo yes | android update sdk --filter build-tools-21.1.1 --no-ui --force > /dev/null
Error: Ignoring unknown package filter 'build-tools-21.1.1'
before_install.11
1.19s$ echo yes | android update sdk --filter tools --no-ui --force > /dev/null
before_install.12
2.30s$ echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
before_install.13
7.11s$ echo yes | android update sdk --filter android-21 --no-ui --force > /dev/null
before_install.14
3.12s$ echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
before_install.15
4.00s$ echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null
before_install.16
3.19s$ echo yes | android update sdk --filter extra-google-m2repository --no-ui --force > /dev/null
before_install.17
3.89s$ echo yes | android update sdk --filter extra-google-google_play_services --no-ui --force > /dev/null
56.27s$ ./gradlew assemble
Downloading https://services.gradle.org/distributions/gradle-2.1-all.zip
[Downloads..]
WARNING: Dependency org.json:json:20080701 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING [Project: :Firext] variant.getProcessManifest() is deprecated. Call it on one of variant.getOutputs() instead.
:Firext:preBuild
:Firext:compileDebugNdk
:Firext:preDebugBuild
:Firext:checkDebugManifest
:Firext:preReleaseBuild
:Firext:prepareComAndroidSupportAppcompatV72100Library
:Firext:prepareComAndroidSupportCardviewV72102Library
:Firext:prepareComAndroidSupportSupportV42102Library
:Firext:prepareComEtsyAndroidGridLibrary104Library
:Firext:prepareComGithubJohnkilAndroidRobototextviewRobototextview210Library
:Firext:prepareComGoogleAndroidGmsPlayServices6171Library
:Firext:prepareComShamanlandFab005Library
:Firext:prepareComSnappydbSnappydbLib050Library
:Firext:prepareDebugDependencies
:Firext:compileDebugAidl
:Firext:compileDebugRenderscript
:Firext:generateDebugBuildConfig
:Firext:generateDebugAssets UP-TO-DATE
:Firext:mergeDebugAssets
:Firext:generateDebugResValues
:Firext:generateDebugResources
:Firext:mergeDebugResources
/home/travis/build/colymore/firext-android/Firext/src/main/res/drawable-hdpi/ic_launcher.png: Error: Cannot run program "/home/travis/build/colymore/firext-android/android-sdk-linux/build-tools/21.1.1/aapt": error=2, No such file or directory
:Firext:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Firext:mergeDebugResources'.
> /home/travis/build/colymore/firext-android/Firext/src/main/res/drawable-hdpi/ic_launcher.png: Error: Cannot run program "/home/travis/build/colymore/firext-android/android-sdk-linux/build-tools/21.1.1/aapt": error=2, No such file or directory
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 28.369 secs
The command "eval ./gradlew assemble" failed. Retrying, 2 of 3.
WARNING: Dependency org.json:json:20080701 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20080701 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING [Project: :Firext] variant.getProcessManifest() is deprecated. Call it on one of variant.getOutputs() instead.
:Firext:preBuild
:Firext:compileDebugNdk UP-TO-DATE
:Firext:preDebugBuild
:Firext:checkDebugManifest
:Firext:preReleaseBuild
:Firext:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
:Firext:prepareComAndroidSupportCardviewV72102Library UP-TO-DATE
:Firext:prepareComAndroidSupportSupportV42102Library UP-TO-DATE
:Firext:prepareComEtsyAndroidGridLibrary104Library UP-TO-DATE
:Firext:prepareComGithubJohnkilAndroidRobototextviewRobototextview210Library UP-TO-DATE
:Firext:prepareComGoogleAndroidGmsPlayServices6171Library UP-TO-DATE
:Firext:prepareComShamanlandFab005Library UP-TO-DATE
:Firext:prepareComSnappydbSnappydbLib050Library UP-TO-DATE
:Firext:prepareDebugDependencies
:Firext:compileDebugAidl UP-TO-DATE
:Firext:compileDebugRenderscript UP-TO-DATE
:Firext:generateDebugBuildConfig UP-TO-DATE
:Firext:generateDebugAssets UP-TO-DATE
:Firext:mergeDebugAssets UP-TO-DATE
:Firext:generateDebugResValues UP-TO-DATE
:Firext:generateDebugResources UP-TO-DATE
:Firext:mergeDebugResources
/home/travis/build/colymore/firext-android/Firext/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-mdpi/abc_btn_radio_to_on_mtrl_000.png: Error: Cannot run program "/home/travis/build/colymore/firext-android/android-sdk-linux/build-tools/21.1.1/aapt": error=2, No such file or directory
:Firext:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Firext:mergeDebugResources'.
> /home/travis/build/colymore/firext-android/Firext/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-mdpi/abc_btn_radio_to_on_mtrl_000.png: Error: Cannot run program "/home/travis/build/colymore/firext-android/android-sdk-linux/build-tools/21.1.1/aapt": error=2, No such file or directory
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.542 secs
The command "eval ./gradlew assemble" failed. Retrying, 3 of 3.
WARNING: Dependency org.json:json:20080701 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING: Dependency org.json:json:20080701 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
WARNING [Project: :Firext] variant.getProcessManifest() is deprecated. Call it on one of variant.getOutputs() instead.
:Firext:preBuild
:Firext:compileDebugNdk UP-TO-DATE
:Firext:preDebugBuild
:Firext:checkDebugManifest
:Firext:preReleaseBuild
:Firext:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
:Firext:prepareComAndroidSupportCardviewV72102Library UP-TO-DATE
:Firext:prepareComAndroidSupportSupportV42102Library UP-TO-DATE
:Firext:prepareComEtsyAndroidGridLibrary104Library UP-TO-DATE
:Firext:prepareComGithubJohnkilAndroidRobototextviewRobototextview210Library UP-TO-DATE
:Firext:prepareComGoogleAndroidGmsPlayServices6171Library UP-TO-DATE
:Firext:prepareComShamanlandFab005Library UP-TO-DATE
:Firext:prepareComSnappydbSnappydbLib050Library UP-TO-DATE
:Firext:prepareDebugDependencies
:Firext:compileDebugAidl UP-TO-DATE
:Firext:compileDebugRenderscript UP-TO-DATE
:Firext:generateDebugBuildConfig UP-TO-DATE
:Firext:generateDebugAssets UP-TO-DATE
:Firext:mergeDebugAssets UP-TO-DATE
:Firext:generateDebugResValues UP-TO-DATE
:Firext:generateDebugResources UP-TO-DATE
:Firext:mergeDebugResources
/home/travis/build/colymore/firext-android/Firext/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-mdpi/abc_btn_radio_to_on_mtrl_000.png: Error: Cannot run program "/home/travis/build/colymore/firext-android/android-sdk-linux/build-tools/21.1.1/aapt": error=2, No such file or directory
:Firext:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Firext:mergeDebugResources'.
> /home/travis/build/colymore/firext-android/Firext/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-mdpi/abc_btn_radio_to_on_mtrl_000.png: Error: Cannot run program "/home/travis/build/colymore/firext-android/android-sdk-linux/build-tools/21.1.1/aapt": error=2, No such file or directory
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.423 secs
The command "eval ./gradlew assemble" failed 3 times.
The command "./gradlew assemble" failed and exited with 1 during .
Your build has been stopped.
To Top

Tip:
Did you know that you can split a build into several smaller pieces? Learn more
How can we help?
Support Ticket
Live Chat
E-Mail us
Documentation
Running Jobs (0)
There are no jobs
Queue (0)
There are no jobs

更新:虚拟机映像已经包括固定的android等待模拟器脚本和android SDK工具版本24.0.0,默认情况下解决了我评论的问题

解决方案-第1期:Appcompat v21.0.2

我建议您尝试在使用工具之前更新平台工具

Tools 23.0.5需要平台Tools 19+,所以我认为您没有更新它。 appcompat-v7:21.0.2需要最后一个需要工具23.0.5的android-m2repository

更新:如果我对问题2的看法正确,那么您正在使用他们预安装的SDK,因此您正在正确更新工具,因为他们预安装了平台工具v20,但如果您解决了问题2,您的问题将是问题1。我不确定第二个问题,因为你们使用的是语言:java,我使用的是语言:android。检查路径并搜索他们的SDK工具
echo$path

备选方案:如果我错了,而你的问题依然存在。我看到你包括了一个可以依赖的图书馆

检查依赖项冲突

  - ./gradlew androidDependencies
  - ./gradlew -q :Firext:dependencies
  - ./gradlew -q :Firext:dependencyInsight --dependency support-v4 --configuration compile
  - ./gradlew -q :Firext:dependencyInsight --dependency appcompat-v7 --configuration compile
您需要android.m2repository中的版本21.0.2,您可以尝试排除它们

compile files('libs/com.mobandme.ada_v2.4.4.jar') {
    exclude group: 'com.android.support'
}

解决方案-问题2:未找到生成工具aapt

我在您的日志中看到未找到
构建工具/aapt
。您正在将
ANDROID\u HOME
添加到
PATH
的末尾,但Travis ci已经先添加了,因此您正在usr/local/ANDROID-sdk-23.0.2上使用他们的
tools/ANDROID
,其中包括构建工具v20.0.0 no 21.1.1

由于您正在使用docker,并且由于另一个问题,您无法将工具更新到23.0.5,因此您可以使用我的工作环境,以便保存已安装的
平台
系统映像
,并可以使用旧的
工具/android
更新到23.0.5。您不需要使用wget下载它:

  - echo "WARNING! delete when fixed";     export OLD_SDK=/usr/local/android-sdk-23.0.2
  - cp -R ${OLD_SDK}/tools ${SDK}/tools || echo "SDK tools copy failed."
  - cp -R ${OLD_SDK}/platforms ${SDK}/platforms || echo "SDK platforms copy failed."
  - cp -R ${OLD_SDK}/system-images ${SDK}/system-images || echo "SDK system-images copy failed."
或者等待他们很快更新虚拟机映像

或者更改顺序,以便使用SDK:

  - export ANDROID_HOME=${TRAVIS_BUILD_DIR}/android-sdk-linux
  - export PATH=${ANDROID_HOME}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}
建议:

您不需要使用wget下载构建工具

我当前正在使用以下更新:

  - echo "LIST SUGGESTED SDK PACKAGES";    android list sdk -e || true
  - echo "LIST AVAILABLE SDK PACKAGES";    android list sdk -a -e || true
  - echo "UPDATE PACKAGES IF REQUIRED";    echo y | android update sdk -u -t platform-tool,tool,\
                                           extra-android-support,extra-google-google_play_services,\
                                           extra-android-m2repository,extra-google-m2repository,\
                                           android-19,sys-img-armeabi-v7a-android-19,\
                                           android-18,sys-img-armeabi-v7a-android-18,\
                                           android-17,sys-img-armeabi-v7a-android-17,\
                                           android-16,sys-img-armeabi-v7a-android-16,\
                                           android-15,sys-img-armeabi-v7a-android-15 || true
  - echo "UPDATE PACKAGES IF POSSIBLE";    echo y | android update sdk -a -u -t ${BUILD_TOOLS},\
                                           android-20,android-21,${SDK_EXTRA_PKGS:-} || true
  - echo "LIST SDK UPDATES BY FILTERS";    android update sdk -u -n -t platform,system-image,\
                                           add-on,extra || true

这在appcompat v-21之前是否有效?这是我第一次用它设置travis ci。因为错误日志显示与appcompat-v21相关的内容,缺少png或类似的内容。
/dev/null
在我看来似乎是sdk安装/更新中的一个问题。和
/home/travis/build/colymore/firext-android/firext/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/drawable-mdpi/abc_-btn_-radio_-to_on_-mtrl_000.png
程序无法访问库的资源,这可能是初始化问题,也可能是由于安装原因。