Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "default gradle wrapper " and "local gradle distribution" in android studio project

Tags:

In android studio when we build the project there are two options for building the project in:

settings->build Tools->Gradle->Project-level settings

The first option is "Use default gradle wrapper" and the second option is "Use local gradle distribution"

My question is which option is faster and when will it be used?

like image 951
0xAliHn Avatar asked Aug 31 '16 11:08

0xAliHn


People also ask

What is default Gradle wrapper?

The default is the current version. Once you have upgraded the wrapper, you can check that it's the version you expect by executing ./gradlew --version . Example: Upgrading the Wrapper version. $ ./gradlew wrapper --gradle-version 7.5.1 BUILD SUCCESSFUL in 4s 1 actionable task: 1 executed.

What is Gradle wrapper properties in Android Studio?

The Gradle wrapper is a script you add to your Gradle project and use to execute your build. The advantages are: you don't need to have Gradle installed on your machine to build the project. the wrapper guarantees you'll be using the version of Gradle required by the project.

Where to find Gradle in Android Studio?

gradle file, located in the root project directory, defines dependencies that apply to all modules in your project. By default, the top-level build file uses the plugins block to define the Gradle dependencies that are common to all modules in the project.


2 Answers

You can read about Gradle Wrapper in the official user guide.

The main thing about the wrapper - it cares about the Gradle version used to build your project. So, if one has configured the project to use a wrapper, then everyone will build it with the same version of Gradle. The version of Gradle could be specified in the configuration file called gradle-wrapper.properties.

One more important thing is that Gradle distribution will be included in your project and if someone will try to build it, no local Gradle installation will be needed.

But if you choose use local gradle distribution, then your project will be built with the version of Gradle you have currently installed and it doesn't guarantees, that your project will be built correctly, since Gradle version may differ.

I don't think, that time is different for this two cases, but wrapper usage seems to be preferable. Sure, in this case, you have to store wrapper distribution in your version control system, but you can set build tool version exactly used to build your project and make no one install Gradle manually if he doesn't have Gradle installed yet.

like image 107
Stanislav Avatar answered Sep 19 '22 18:09

Stanislav


I want to add a very important point to the Stanislav's answer. Gradle could be used not only for building your project from Android Studio, but also the from command line. This is especially important if you want to build it in CI environment. In that case, you don't need to care about specific gradle version on your server. The project will be built with the same version for both IDE and CI and this will make your build stable and predictable.

like image 23
Geralt_Encore Avatar answered Sep 19 '22 18:09

Geralt_Encore