41

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.

Renier
  • 1,738
  • 3
  • 24
  • 51

17 Answers17

29

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

Junaid
  • 4,822
  • 2
  • 21
  • 27
19

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.

apmartin1991
  • 3,064
  • 1
  • 23
  • 44
  • 2
    Thanks I will try that, How do you clear the cache for android studio? – Renier Jun 12 '15 at 09:49
  • 16
    I believe there is a "invalidate caches / restart" in Menu File. – sschrass Jun 12 '15 at 09:55
  • 1
    @apmartin1991 I did restart my pc but no effect. So the process continues when I disable the proxy settings but then it cant download the gradle zip file... ? so it fails again. Please see my updated post. – Renier Jun 12 '15 at 10:21
  • I used another Internet source and it downloaded the gradle and the process continued. Thanks for you help. – Renier Jun 12 '15 at 10:36
  • 1
    No worries, if the answer was correct then please mark it as correct, if you needed to do something else then please answer your own question and then mark it as correct so that future people will know what fixed it for you :) – apmartin1991 Jun 12 '15 at 13:29
  • In my case all options in file menu are disabled, even unable to close current project, any suggestion guys? Thanks – NotABot Jan 23 '18 at 09:50
  • It isn't the answer. simply it was wrong path in the file->settings->tools->gardle .. just remove the path then apply – Shady Mohamed Sherif Apr 12 '18 at 19:52
7

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

Community
  • 1
  • 1
sajjadG
  • 2,546
  • 2
  • 30
  • 35
7

Change gradle home directory to exist location.

Pang
  • 9,564
  • 146
  • 81
  • 122
2

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.

akdd
  • 51
  • 1
  • 4
2

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.

Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66
2

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
Hoque MD Zahidul
  • 10,560
  • 2
  • 37
  • 40
2

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

Siva Prakash
  • 4,626
  • 34
  • 26
2

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

Abhishek Mathur
  • 478
  • 5
  • 12
1

Turning off my VPN solved this for me.

Marmoy
  • 8,009
  • 7
  • 46
  • 74
1

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~

Suki
  • 37
  • 5
1

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.

Community
  • 1
  • 1
Sourav Roy
  • 323
  • 4
  • 12
1

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.

1

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.
Ayub
  • 2,345
  • 27
  • 29
0

If you are loading existing project into new Android studio then it's gradle library version that you have specified in your top level build.gradle file. Check version and move to latest or compatible version for android studio.

Sagar Yadav
  • 137
  • 2
  • 11
0

In my case it was a wrong path in the file->settings->tools->gardle .. just remove the path then apply.

Then restart android studio (you may need to end task)

Shady Mohamed Sherif
  • 15,003
  • 4
  • 45
  • 54
-2

If you get a connection timed out error this is usually a problem of proxies. Try disabling them if you are using proxies.

Also, when gradle is stuck, deleting the .gradle folder in c:\Users\ always helped me.

Tom Aranda
  • 5,919
  • 11
  • 35
  • 51
alireza easazade
  • 3,324
  • 4
  • 27
  • 35
  • I should have read the other answers before editing. This answer does not really contribute anything new. All of this is covered in the accepted answer . – Tom Aranda Dec 21 '17 at 15:23