Skip to content

Use gradle zip in local system without downloading it everytime using gradle-wrapper

As of now, Android Studio needs a fast and stable internet connection to implement a Gradle project. For some reason, the app developers are forced to have a stable connection for the Gradle build system to work. Meanwhile after the issue is addressed to the team for the first time, a setting is introduced in their later release for that the users should be able to use a local copy of gradle, but still, it doesn’t seem to stand well. The developer team of Android Studio even after considering the network requirement and other bugs in IDE, they are currently prepared to give priority to other functionalities. Hope they provide a stable solution for the offline working of Gradle.

The option they have introduced is “Gradle Offline mode”. What this new option does is tell the Gradle build system to stop checking for an internet connection, and utilize the cached copies of available resources instead.

The case that declared this as a broken option is because that it still assumes that you will need to have a network connection, most preferably a stable one.

Usually, Android Studio takes a lot of time like around 2-5 minutes or even 10 minutes to build and Gradle sync a project, with a slow or unstable internet connectivity. Also at the time of syncing the gradle after making changes to the gradle build file, it would seem to lock up again for 5 to 10 minutes.

No matter if you use offline mode option or not, you are going to need a fast and stable network connection for the things to work right, unless Android Studio officially removes the network requirement.

Currently, the only available solution is to use a completely offline gradle distribution file and redirecting the gradle distribution Url to this local file.

After searching all over the internet for a solution and finding no proper answers for this, finally, I have found the solution. I’m going straight to the point!

 

Changing the distributionUrl in your  gradle-wrapper.properties file will do the job! The default distributionUrl that is generated in the ProjectFolder\gradle\wrapper\ gradle-wrapper.properties file points to the gradle file located somewhere in their server, whose Url looks like

distributionUrl=http\://services.gradle.org/distributions/gradle-x.xx-bin.zip”

 

 

And the solution is to download a local copy of the gradle distribution zip file and use it instead!

 

 

 

    • Save the downloaded zip file to Users/YOURPC/.gradle/ folder and then just change the distributionUrl in your gradle-wrapper.properties file to point to your local file.

 

    • In my case, the new distributionUrl looks like

    • distributionUrl=file\:///C:/Users/Guru/.gradle/gradle-3.3-all.zip

 

 

One of my gradle-wrapper.properties files now looks like

 

There you are! No more internet connection is required to run a gradle project. It will need a connection only if your project requires other repositories and external library dependencies!

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top