android - 特拉维斯安卓构建错误

标签 android gradle android-gradle-plugin continuous-integration travis-ci

我收到以下错误:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/travis/build/ir2pid/AndroidPOC2/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Minimum supported Gradle version is 4.1. Current version is 4.0.1. If using the gradle wrapper, try editing the distributionUrl in /home/travis/build/ir2pid/AndroidPOC2/gradle/wrapper/gradle-wrapper.properties to gradle-4.1-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 40s

travis_time:end:06d6b207:start=1527276803217824665,finish=1527276844181358996,duration=40963534331
[0K
[31;1mThe command "gradle wrapper --gradle-version 4.1" failed and exited with 1 during .[0m

Your build has been stopped.
  1. 我上传了 gradlew、gradle-wrapper.properties、gradle-wrapper.jar
  2. 尝试让 gradlew 和 gradle-wrapper.jar 在 .travis.yml 中可写
  3. 甚至在 .travis.yml 脚本中安装了 gradle 4.4

gradle-wrapper.properties

#Fri May 25 21:05:26 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

.travis.yml

install: gradle wrapper --gradle-version 4.4
language: android
android:
  components:
    - tools
    - platform-tools

    # The BuildTools version used by your project
    - build-tools-26.0.2

    # The SDK version used to compile your project
    - android-26

    # Additional components
    - extra-google-google_play_services
    - extra-google-m2repository
    - extra-android-m2repository
    - addon-google_apis-google-26

before_script:
- chmod a+x gradlew
- chmod a+x gradle/wrapper/gradle-wrapper.jar

script: gradlew build

最佳答案

将这段代码与你的进行比较,注意:

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
}

顶级gradle构建文件(build.gradle):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()
        //To get a Git project into your build
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
        google()
        //To get a Git project into your build
        maven { url 'https://jitpack.io' }
    }
}

gradle-wrapper.properties:

#Mon Jan 1 13:51:26 PDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip

关于android - 特拉维斯安卓构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50535904/

相关文章:

android - 当设备进入休眠模式时, Activity 状态是什么?

android - 动态主题色

gradle - Gradle/TestNG:使用suiteXmlBuilder()时如何在build.gradle中指定testng包含组?

安卓工作室 : Gradle sync failed: Project :app declares a dependency

react-native - react native : Error: Duplicate resources - Android

android - 从网络下载 Artifact 时,Gradle发生了错误

java - 如何重用线程?线程什么时候关闭?

android - 发布版本 : transformClassesAndResourcesWithProguardForRelease FAILED

java - 如何删除正确的Android fragment 实例

java - 无法从布局文件夹引用布局