特拉维斯android构建错误

问题描述 投票:4回答:3

我收到以下错误:

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. 尝试在.travis.yml中编写gradlew和gradle-wrapper.jar
  3. 甚至在.travis.yml脚本中安装了gradle 4.4

grad了-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
android gradle android-gradle continuous-integration travis-ci
3个回答
0
投票

将此代码与您的代码进行比较,请注意:

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' }
    }
}

grad了-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

0
投票

我认为问题是你没有在gradlew之前添加./

language: android
jdk: oraclejdk8
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

script: ./gradlew build

0
投票

这是同一个项目的工作配置。

travis.yml

language: android

env:
  matrix:
    - ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a

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-19
    - android-26

    # Additional components
    - extra-google-google_play_services
    - extra-google-m2repository
    - extra-android-m2repository
    - addon-google_apis-google-26
    - extra-android-support
    - sys-img-${ANDROID_ABI}-${ANDROID_TARGET}

script:
  - ./gradlew build 
  #- ./gradlew lint test connectedAndroidTest 
  #- ./gradlew build jacocoTestReport --stacktrace

gradle这个/包装/ gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

项目级别.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.0.1"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

app level .gradle android {

compileSdkVersion 26
defaultConfig {
    applicationId "xx.xx.xx"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
}
© www.soinside.com 2019 - 2024. All rights reserved.