Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio stuck at Refreshing Gradle project

Updated Android studio to 1.2.2 and the background process wont end.(Refreshing 'MemoryCards' Gradle project).

It has been more than an hour now and its still busy?

enter image description here

Is this normal and why is it taking this long? its a small app.

Here is my idea.log : https://www.dropbox.com/s/syf12m3lxbww5k7/idea.log?dl=0

Update:

Disabled my proxy settings in android studio and the refreshing process continued and showed me the following. enter image description here

It failed at the download of the gradle zip :

enter image description here

So the reason I think that It takes this long it was trying to download the gradle zip file +- 60 Mb and my internet connection is slow...

So the process continues when I disable the proxy settings but then it cant download the gradle zip file... ? so it fails again.

Update :

I used another Internet source and it downloaded the gradle and the process continued.

like image 967
Renier Avatar asked Jun 12 '15 09:06

Renier


14 Answers

In Android Studio select:
File\Settings\Build, Execution, Deployment\Build tools\Gradle
click on the button on the right side showing local gradle distribution path.
you will be taken to the gradle folder.
click ok in this dialog box and your path will be updated!

restart android studio and you are good to go!

The Problem:
in my case path selected after the update was of older version e.g:
C:/Program Files/Android/Android Studio/gradle/gradle-2.4
However, after the update it was changed to:
C:/Program Files/Android/Android Studio/gradle/gradle-2.8

P.S:
This solution also resolves following error:
buildTypes cannot be applied to groovy.lang.Closure

like image 76
Junaid Avatar answered Oct 05 '22 11:10

Junaid


A few things to try in the following order:

  1. Restart the entire PC, then try again...

  2. If that fails then clear the cache for android studio, restart
    android studio and try again..

  3. Disable any proxies on your PC / network / Android studio then try again

If that doesn't work then look at clearing the gradle files and re-downloading them. Let me know how this goes please and I can update my answer with further things to do if needed.

like image 36
apmartin1991 Avatar answered Oct 05 '22 12:10

apmartin1991


As this answer suggests, Removing .gradle directory from home helps solving this problem in some cases.

like image 39
sajjadG Avatar answered Oct 05 '22 13:10

sajjadG


Change gradle home directory to exist location.

like image 28
Lloric Mayuga Garcia Avatar answered Oct 05 '22 11:10

Lloric Mayuga Garcia


I run into this problem on Windows 7 after an update of the Android studio and this works for me:

Run the Android Studio with Administrative Privileges.

like image 40
akdd Avatar answered Oct 05 '22 13:10

akdd


I had the same issue. I just updated my android studio to 2.0 on ubuntu 14.04. This issue arose for one of the project and it was solved through a answer here which seems unrelated to this problem !!

If you are using Android Studio 2.0 Beta, this issue might appear (more likely if you are working on NTFS filesystem) and it seems like the "Instant Run" is the culprit. Search for "Instant Run" in settings and uncheck the box

Posting here to an old question - maybe somebody else might me stuck on this aswell.

like image 21
Rachita Nanda Avatar answered Oct 05 '22 11:10

Rachita Nanda


This happened to me quite a few times and there is no single solution.You should try some of the solutions mentioned below.

  1. File -> Invalidate Caches / Restart
  2. Update Android studio and Gradle to the latest version
  3. Select the correct Gradle distribution by going to Settings/Preferences -> Build,Execution, Deployment -> Gradle and select the path for local Gradle distribution

  4. Restart your computer

like image 23
Siva Prakash Avatar answered Oct 05 '22 13:10

Siva Prakash


These steps work for me :

  1. Close android studio first
  2. Go to folder C:\Users\.gradle and delete that folder.
  3. Then in gradle folder create gradle.properties file and add following lines.
 org.gradle.daemon=true
 org.gradle.parallel=true
  1. Open android studio
like image 27
Cool_Ashish Avatar answered Oct 05 '22 12:10

Cool_Ashish


Turning off my VPN solved this for me.

like image 24
Marmoy Avatar answered Oct 05 '22 12:10

Marmoy


You can reverse to Android Studio 1.4, then the project works.....

And when I update it to 1.5, the project start stucking with refreshing >_<

Might not help, but worth a try~

like image 27
Suki Avatar answered Oct 05 '22 13:10

Suki


Answer of Lloric is the perfect answer.

Go to Settings > Build Tools > Gradle

Then change the Gradle Home path to the existing path.

Probably you are facing problem now with gradle-2.10

Browse directory, you will find out gradle-2.14.1 as of mine or later versions.

Change it to that then rebuild your project.

like image 21
Sourav Roy Avatar answered Oct 05 '22 12:10

Sourav Roy


In my case, I download Gradle zip from the web site, and set the gradle local home, enabled offline work. Then "file" menu -> restart. It worked for me.

like image 24
Ruize Zhang Avatar answered Oct 05 '22 12:10

Ruize Zhang


if gradle has downloaded correctly and you just have problem with this project, follow these steps:

  1. Delete .gradle folder from your project's root.
  2. File > Invalidate Caches/restart.

Stucking gradle in adnroid studio

Note: if android studio didn't restarted, kill it's process in Task Manager.

Some other solutions:

  • Adding android studio to Firewall and Antivirus exceptions (or turn off both temporary)
  • Adding mavenCentral() to project build.gradle after jcenter() line.
like image 32
Ayub Avatar answered Oct 05 '22 12:10

Ayub


In your terminal try :

gradlew clean

Then invalidate caches and its works... It will redownload all libraries from internet and build successfully You can also delete build,.gradle,gradle folders to force re-cleaning

like image 23
Abhishek Mathur Avatar answered Oct 05 '22 12:10

Abhishek Mathur