Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Android Studio download gradle each time a new gradle project is imported?

Why does Android Studio download gradle every time I try to import a new project?

Initially, I imported one gradle project for which Gradle 2.1 was auto-downloaded. Subsequently, for a second project import, it downloaded Gradle 1.10. Now again while importing a third project, it has downloaded Gradle 2.2.1.

What is happening?

like image 414
touchchandra Avatar asked Jan 01 '15 16:01

touchchandra


People also ask

Why does Android Studio download Gradle for every project?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.

Why is Gradle keeps downloading itself again and again with Android Studio?

Enable offline mode in Android Studio to disable checking for updates everytime. Go to Settings>Compiler>Gradle>Offline mode. If this is enabled the gradle will be told not to connect to internet and check for updates.

How do I force Gradle to sync?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.

Do you need to download Gradle?

Android Studio comes with a working installation of Gradle, so you don't need to install Gradle separately in that case. In order to create a new build or add a Wrapper to an existing build, you will need to install Gradle according to these instructions.


2 Answers

Projects can declare which Gradle they require to run (see gradle.properties file in gradle directory in the root of the project).

Android Studio uses this information to download and run the right version (it's actually not Android Studio, it's the Gradle Wrapper running inside it). And it's a good thing.

What you can do?

  1. Wait. Once you have the version downloaded in ~/.gradle directory, it will be used for any project declaring the same version. It's one-time cache.
  2. Disable the usage of the wrapper when you import the project. I really recommend against it! You project might not build because of that.
like image 167
JBaruch Avatar answered Oct 27 '22 15:10

JBaruch


Same happens to me.

The answer of JBaruch is allright.

1.- When you're opening a file on the option Gradle project: select the build.gradle that cames on your project

2.- Select the option "Use local grade distribution" and in Gradle home option; go and select in C:\Program Files\Android\Android Studio\gradle\gradle-2.2.1

It will not ask you to download it again (except if needs other version)

like image 34
jornhymcfly Avatar answered Oct 27 '22 14:10

jornhymcfly