子模块中的Gradle包装器版本与项目根目录中的不同

时间:2014-11-12 10:49:30

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

我是Android studio& amp;的新手摇篮。

我的项目结构是这样的:

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

项目根 build.gradle 使用Android插件版本0.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工作室中,文件 - >项目结构 - >显示Gradle 2.1

为什么gradle包装器在子模块中显示的不同于项目根目录?如何让我的所有子模块都使用Gradle 2.1?

1 个答案:

答案 0 :(得分:2)

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