【问题标题】:Gradle wrapper version in sub-module is different than in project root子模块中的 Gradle 包装器版本与项目根目录中的不同
【发布时间】:2015-01-09 04:40:54
【问题描述】:

我是 Android Studio 和 Gradle 的新手。

我的项目结构是这样的:

MyProject
  -LibModuleOne
    -...
    -build.gradle
  -LibModuleTwo
    - ...
    -buld.gradle
  -AppModule
    -...
    -build.gradle
buld.gradle

在命令行上,在 MyProject/ 下,./gradlew --version 显示我正在使用 gradle 2.1

./gradlew --version

------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------

Build time:   2014-09-08 10:40:39 UTC
Build number: none
Revision:     e6cf70745ac11fa943e19294d19a2c527a669a53

Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_25 (Oracle Corporation 25.25-b02)
OS:           Mac OS X 10.8.5 x86_64

但是,如果我检查 MyProject/LibModuleOne/MyProject/LibModuleTwo/MyProject/AppModule/ 下的版本,它们都会显示给我我正在使用 gradle 1.12

./gradlew --version

------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------

Build time:   2014-04-29 09:24:31 UTC
Build number: none
Revision:     a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:          2.2.0
JVM:          1.8.0_25 (Oracle Corporation 25.25-b02)
OS:           Mac OS X 10.8.5 x86_64

project rootbuild.gradle声明使用Android插件version0.13.3:

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

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.3'
    }
} 

在Android studio中,File-->Project structure-->显示Gradle 2.1

为什么 gradle wrapper 在子模块中显示的版本与项目根目录不同?如何让我的所有子模块都使用 Gradle 2.1?

【问题讨论】:

    标签: android gradle android-studio android-gradle-plugin gradlew


    【解决方案1】:

    您似乎安装了多个包装器(否则 ./gradlew 将无法在子目录中工作)。您需要删除所有gradlew 脚本和gradle/wrapper 目录,根项目目录中的目录除外。

    【讨论】:

      猜你喜欢
      • 2016-11-29
      • 1970-01-01
      • 2016-01-05
      • 2020-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-06
      • 2019-01-20
      相关资源
      最近更新 更多