Android Studio:“使用默认 gradle 包装器”与“使用可自定义的 gradle 包装器”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24811997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio: "Use default gradle wrapper" vs. "Use customizable gradle wrapper"
提问by ZenBalance
What exactly is the difference between Android Studio's Gradle options:
Android Studio 的 Gradle 选项之间到底有什么区别:
Android Studio->Preferences->Gradle
Android Studio->Preferences->Gradle
Use default gradle wrapper (recommended)
and Use customizable gradle wrapper
?
Use default gradle wrapper (recommended)
和Use customizable gradle wrapper
?
Background:
背景:
I am working on an Android project in Android Studio and using a Gradle wrapper.
我正在 Android Studio 中开发一个 Android 项目并使用 Gradle 包装器。
However, when I use the Android Studio settings "Use customizable gradlew wrapper" every time my team members sync the Android Studio project using the gui command:
但是,每当我的团队成员使用 gui 命令同步 Android Studio 项目时,当我使用 Android Studio 设置“使用可自定义的 gradlew 包装器”时:
they find the gradle/wrapper/gradle-wrapper.properties
date being updated (and resulting in a extra diffs on the git repo).
他们发现gradle/wrapper/gradle-wrapper.properties
正在更新的日期(并导致 git repo 上的额外差异)。
Switching to "Use default gradle wrapper" seems to solve this issue.
切换到“使用默认 gradle 包装器”似乎解决了这个问题。
回答by ChrLipp
See the IntelliJ IDEA help here:
请在此处查看 IntelliJ IDEA 帮助:
- Using the default gradle wrapper means that Gradle controls the version number
- Using the customizable gradle wrapper means that IDEA controls the version number of the gradle wrapper.
- 使用默认的 gradle 包装器意味着 Gradle 控制版本号
- 使用可定制的 gradle 包装器意味着 IDEA 控制 gradle 包装器的版本号。
The version number is stored in gradle/wrapper/gradle-wrapper.properties
. So when you choose "using the customizable gradle wrapper" each time you are opening the project with IDEA, it will change the property file to adjust the wrapper version you specified in the IDEA project.
版本号存储在gradle/wrapper/gradle-wrapper.properties
. 所以当你每次用IDEA打开项目时选择“使用可定制的gradle wrapper”时,它会改变属性文件来调整你在IDEA项目中指定的wrapper版本。
For the sake of repeatable builds (even on your continuous build server which doesn't run IDEA) let Gradle control the version number and use the default gradle wrapper.
为了可重复构建(即使在不运行 IDEA 的连续构建服务器上),让 Gradle 控制版本号并使用默认的 gradle 包装器。
You can set the version number which is used by Gradle inside your build.gradle
with
您可以在您的build.gradle
with 中设置 Gradle 使用的版本号
// needs at least Gradle V1.7
wrapper {
gradleVersion = '2.2.1'
}
or
或者
// works with every Gradle version
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
Remark:don't forget that this configuration is only used for the generation of the wrapper. To activate it, you have to execute the generation with gradlew wrapper
. This tasks updates the gradle-wrapper.properties
which is used afterwards for all wrapper executions.
备注:不要忘记此配置仅用于生成包装器。要激活它,您必须使用gradlew wrapper
. 此任务更新了gradle-wrapper.properties
之后用于所有包装器执行的 。