234

I have installed the new Android Studio. Everything was working fine but when I try to create a new project it gets stuck at downloading Gradle.

Is there any way to install the Gradle required by Android Studio manually? Or any other method to solve this problem ?

screenshot

Jonathan Soifer
  • 2,715
  • 6
  • 27
  • 50
Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76
  • 1
    i just closed the studio and restarted the studio and it took few minutes and i was able to run a sample project. try closing and restarting may be it will help – Raghunandan May 16 '13 at 06:58
  • have you tried to create a new project in it? – Vipul Purohit May 16 '13 at 06:59
  • I have created new project now, but throwing some dependency error...in hello world project – JNI_OnLoad May 16 '13 at 07:00
  • I have same issue try to open gradle in browser to connect with site. check internet connection as well. I have tried these multiple time and that will work. – user1621629 May 16 '13 at 07:00
  • Gradle is working fine in browser and I am working with a high speed broadband connection so no issue with internet connection. – Vipul Purohit May 16 '13 at 07:02
  • Doesn't Gradle come already with the Android Studio bundle? – bad_keypoints Jul 20 '13 at 15:33
  • @Jeet is correct. This may take even **hours** to download!! Even with Verizon FIOS!!! I'm not kidding!! It must have to do with the Gradle website. If you want proof, try Arya's suggestion and try to download it manually. – Jim G. Dec 14 '13 at 04:13
  • https://stackoverflow.com/a/32759390/1190276 you can download the zip yourself :) – Abhigyan Mar 09 '20 at 04:02
  • I don't know. Why they don't show a prompt before downloading all Gradle versions. If you change the wrapper version it will work. `Gradle please reduce network usage.` https://i.stack.imgur.com/O2IU9.png – Qamar Mar 24 '21 at 11:18

18 Answers18

198

It is not stuck, it will take some time normally 5-7 mins , it also depends upon internet connection, so wait for some time. It will take time only for first launch.

Update: Check the latest log file in your C:\Users\<User>\.gradle\daemon\x.y folder to see what it's downloading.

user3666197
  • 1
  • 6
  • 50
  • 92
JNI_OnLoad
  • 5,472
  • 4
  • 35
  • 60
  • 536
    a download progress bar wouldn't hurt anyone – abbood Jun 17 '13 at 11:27
  • 1
    @acdcjunior no wonder it takes 5 or 7 minutes for 50 MB?? Maybe 10 years ago, come on... The very same file downloads in less than 10 seconds via web browser! What is Android Studio doing?? – Konrad Morawski Aug 31 '14 at 10:01
  • 1
    @KonradMorawski It is not about the size only. Android Studio's fault on this is about not [providing feedback, recognition, visibility of what's happening](http://www.nngroup.com/articles/ten-usability-heuristics/) to the user. Those, along network delay, are facts and should not be ignored. From your rationale, no application should have a progress bar (if it downloaded something less than 50mb) and, well, I think you see my point here. – acdcjunior Aug 31 '14 at 17:30
  • Kill the process, then restart studio. The download will be background. LOL. – sad1e Oct 02 '14 at 02:32
  • You can look in the latest log file in your C:\Users\\.gradle\daemon\x.y folder to see what it's downloading. If the last line in the log is a download then just leave it at least 10 minutes and check the log again – FrinkTheBrave Oct 30 '14 at 07:06
  • 9
    I suspect Google's developers use VERY high-end machines for development. Their CPUs are fast; networks are fast. The downloads would just take a split of second for them, so they don't care about the _progress bar_. See how much RAM Google Chrome is taking. **(BTW, the download already taking more than half an hour for me.... (I am on a decently fast network though))** – cychoi Nov 23 '14 at 15:55
  • In Windows, You may refer to **\Users\\.gradle\wrapper\dists** to see that it is actually downloading the Gradle distribution by *watching the folder size slowly grows* over time. This size can be compared to the specific downloaded [Gradle release](https://gradle.org/releases) to get indication about how much left to be downloaded. What a weird workaround instead of using a download bar. – Eido95 Mar 12 '17 at 20:53
  • To manually download gradle you can use this : https://stackoverflow.com/questions/31405947/how-to-setup-gradle-2-2-1-all-zip-manually/32759455#32759455 – Abhigyan Jun 08 '17 at 17:47
64

Yes, There is.

  1. Create a new project and you should Shutdown The Android Studio Application.(Because it takes a long time for you).
  2. Goto C:\Users\{Logged in User}\.gradle folder
  3. There is a folder there that show you which version of gradle Android Studio requires (e.g. gradle-1.8-bin)
  4. Download this version from internet (e.g. gradle-1.8-bin.zip).
  5. Goto C:\Users\{Logged in User}\.gradle\wrapper\dists\gradle-1.8-bin
  6. There is a folder here that its name is like a GUID.
  7. You should just copy the zip file that you've already downloaded from internet into this folder.
  8. Execute Android Studio and create a new project.
Reza
  • 1,004
  • 8
  • 15
  • 3
    For some reason when I was letting the android studio download the gradle-1.9-all.zip it was downloading it at hardly 10% of my internet speed. Manually downloading it was faster. – Prathamesh Gharat Jan 01 '14 at 12:54
  • 1
    Not only gradle itself, it also take decades to download maven dependencies, average minutes for each KB size jar. – yorkw Jul 08 '14 at 09:34
  • these dependencies should be packaged and managed internally for their updates just like AVD Manager by the android studio. It just makes android studio a more fragmented software now with all pieces here and there. – Ankit Tanna May 23 '15 at 05:54
  • What I am finding is it is extremely difficult to download from gradle's server even if internet speed is good. I am working on more than 3 MBps download speed and still Gradle takes 40 mins to download 62 MB file. Servers are slow.!! – Ankit Tanna May 23 '15 at 05:56
  • This works a charm. The `crux` of the matter is that gradle is not backward compatible and you need a specific version of gradle to build correctly. That is a problem. – tread Jul 27 '15 at 07:29
  • gradle servers are currently extremely slow, so I downloaded gradle here: https://distfiles.macports.org/gradle/ – Sébastien Apr 14 '20 at 15:10
21

I found the same issue happening on my laptop, despite waiting for quite a long time. This is what I did and it worked for me. Just force close the Android Studio and launch it again. This time, just open the existing project and let it take care of finishing up the process of building/downloading.

Another option that you could possibly try is that if you look into File --> Settings, there is an option for Gradle location. You could go to the Gradle download site, download a local distribution of Gradle and point the Gradle location to that local directory.

Romin
  • 8,708
  • 2
  • 24
  • 28
15

If you're using OS X, and it continues to hang indefinitely, I'd recommend shutting down Android Studio (may have to force kill), then going to your ~/.gradle directory on the console. You'll see a wrapper/dists directory there and whatever version of gradle AS is trying to download. Check the timestamp of the download underneath the randomly named subdirectory. If you see that it is never changing, most likely your download was interrupted and AS wasn't able to restart it properly and will not unless you delete everything below the dists directory and start over.

So, with AS shutdown delete everything below ~/.gradle/wrapper/dists and then try again with a new project in AS. You can check the progress of the gradle download file (it will end in .part) to make sure that it's growing. Give it plenty of time as it IS a large file.

That's what finally worked for me.

Terry Ray
  • 300
  • 3
  • 11
8

Solution :

1). Delete the C:\Users\username.gradle folder

2). Download http://downloads.gradle.org/distributions/gradle-2.2.1-all.zip

3). Create a new project in android studio.

4). When this time it stucks at gradle building, Force close the android studio.

5) Now go to C:\Users\username.gradle\wrapper\dists\gradle-2.2.1-all\c64ydeuardnfqctvr1gm30w53 (the end directory name may be different)

6) Delete gradle-2.2.1-all.zip.lck and other files from this directory.

7) Paste the new downloaded gradle-2.2.1-all.zip here.

8) Run the android studio. :)

Abhigyan
  • 641
  • 10
  • 25
5

Note : My answer seems quite long but its only 2 steps away if you want a correct way to configure with current project.

I found what was the actual problem. Actually, each android project comes with its own version of gradle wrapper.

have a look at dir

projectname/gradle/wrapper

here the properties file says the version of gradle that this project uses:

#Mon Sep 08 13:53:18 PDT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip

So the issue is if you dont have that version of gradle then it will download that version for you. For instance have a look at this dir, where it downloaded gradle versions for me

/home/myusername/.gradle/wrapper/dists

looks like

enter image description here

Here it will try to download version of gradle if you dont have. If you are comfortable with downloading other version of gradle then you can wait till it completes else

Workaround will be: 1. if project is on git clone it first.

  1. goto your projectdir/gradle/wrapper

3.change version of distributionUrl to version that you already have : eg: for 2.2.1-all

url will be

distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

4.copy gradle-wrapper.jar to your projectdir/gradle/wrapper from

.gradle/wrapper/dists/gradle-2.1.1-all/4ryh47z6pv2tj9n03uiw8pzc6/gradle-2.2.1/lib/gradle-wrapper.jar(dont forget to rename gradle-wrapper2.2.1.jar to gradle-wrapper.jar)

  1. now import your project in studio.. and it works.
swapyonubuntu
  • 1,952
  • 3
  • 25
  • 34
4

Gradle is actually included with Android Studio (at least on the Mac OS X version.) I had to point it to the installed location, inside the Android Studio application "package contents" (can view by control/right-clicking on the application icon.)
Location of gradle inside Android Studio package

race_carr
  • 1,387
  • 12
  • 21
4

Yes, You can install Gradle manually before Android Studio, first install gradle in any location then add de gladle location to path variable (in Environment Variables Window).

alexove
  • 41
  • 1
3

I had fixed this problem by removing the .gradle folder

in windows: C:\Users{Logged in User}.gradle

Moamen Mostafa
  • 349
  • 3
  • 6
3

For Windows Users

Use your Network Resource Monitor

enter image description here

Open Task Manager [Ctrl+Shift+Esc]

Performance Tab

Open Resource Monitor (From the bottom)

First i decided to wait after reading answers here. But how long..? How to make sure it will finish.? They should have provided percentage of download, but they have not. So to know some kind of progress is going on, open this network resource monitor, it will show you some kind of download is going on for the Studio64.exe. IF not (if it shows 0B/Sec), then either network is not available or the application is not responding.

Abdul Saleem
  • 10,098
  • 5
  • 45
  • 45
2

What worked for me:

  1. Create a dummy project, when it gets stuck on the Build screen, kill the studio process.
  2. Open the android studio and open the project, the projet will be broken
  3. Create a new project with the dummy project already opened it will create the project without problems
  4. Close the dummy project and have fun
Panthro
  • 3,247
  • 2
  • 32
  • 37
2

Invalidate Caches and Restart

It worked for me.

Shadab K
  • 1,677
  • 1
  • 16
  • 25
1

The gradle included with Android Studio is located in /Applications/Android Studio.app/plugins/gradle/lib

To go into the Android Studio.app directory I did cd "Android Studio.app"

or you could just do cd /Applications/Android\ Studio.app/plugins/gradle/lib

1

This was also taking along time for me (slow connection).

On Ubuntu (16.04), I was able to monitor the download progress by looking in:

~/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/ 

running ls -al from this directory showed the gradle-3.3-all.zip.part file continuing to grow.

The file ended up being 88M.

Please note the 55gk2rcmfc6p2dg9u9ohc3hw9 (and gradle version) may be different for you, please change your command accordingly.

veggiebenz
  • 389
  • 5
  • 12
1
  1. Open gradle-wrapper.properties
  2. Change From: distributionUrl=https/://services.gradle.org/distributions/gradle-4.4-all.zip To: distributionUrl=http://services.gradle.org/distributions/gradle-4.4-all.zip

Note: 1. I dont care about SSL disable for downloading the gradle, but others might be sensitive, so its up to you. 2. Notice the gradle version, in my case its 4.4.

go to gradle-wrapper.properties

change https to http, and if there is a froward slash after https remove it

Result: Success

Omar N Shamali
  • 503
  • 5
  • 11
1

The Gradle popup window only shows intermittent progress and is not very helpful in understanding if the download is actually stuck or is very slow.

enter image description here

It will help to build your app from the command line where you can actually get the real progress of downloading with

./gradlew build

enter image description here

Vihaan Verma
  • 12,815
  • 19
  • 97
  • 126
0

Android Studio comes with Gradle, but it does not have the command line gradle functionality.

0

Quick Fix: Just turn off your firewall, it seems that android studio wants to download something and because our firewall prevents it from downloading the file that it wants it becomes stuck.

Note: Turning your firewall off can lower your security, if you have time you can just allow android studio in your firewall. By doing this you can turn on your firewall while allowing android studio to download anything that it wants.

Cary Bondoc
  • 2,923
  • 4
  • 37
  • 60