1

我是 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

项目根目录的build.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 在子模块中显示与项目 root 不同的版本?如何让我的所有子模块都使用 Gradle 2.1 ?

4

1 回答 1

2

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

于 2014-11-12T13:01:59.003 回答