Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
187 views
in Technique[技术] by (71.8m points)

Android Studio: "Use default gradle wrapper" vs. "Use customizable gradle wrapper"

What exactly is the difference between Android Studio's Gradle options:

Android Studio->Preferences->Gradle

Use default gradle wrapper (recommended) and Use customizable gradle wrapper?

Background:

I am working on an Android project in Android Studio and using a Gradle wrapper.

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:

enter image description here

they find the gradle/wrapper/gradle-wrapper.properties date being updated (and resulting in a extra diffs on the git repo).

Switching to "Use default gradle wrapper" seems to solve this issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

See the IntelliJ IDEA help here:

  • 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.

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.

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.

You can set the version number which is used by Gradle inside your build.gradle with

// 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...