Manually install Gradle and use it in Android Studio

282,818

Solution 1

Android Studio will automatically use the Gradle wrapper and pull the correct version of Gradle rather than use a locally installed version. If you wish to use a new version of Gradle, you can change the version used by studio. Beneath your Android Studio's project tree, open the file gradle/wrapper/gradle-wrapper.properties. Change this entry:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip

Solution 2

https://services.gradle.org/distributions/

Download The Latest Gradle Distribution File and Extract It, Then Copy all Files and Paste it Under:

C:\Users\{USERNAME}\.gradle\wrapper\dists\

Solution 3

Step 1: Go to the download site from Gradle: https://gradle.org/releases/

Step 2: Extract the downloaded zip file into a directory.

Step 2: Hit Ctrl + Alt + S (mac: ⌘ + ,) in Android studio/Intellij IDEA

Step 3: Goto: Build, Execution, Deployment >> Build Tools >> Gradle (Or just type in the searchbar Gradle)

Step 4: Select: (X) Use local gradle distribution and set Gradle home to your extracted Gradle directory. Click on apply.

Step 5: Get rid of your unnecessary gradle files delete:
- MyApp/gradle/
- gradlew
- gradlew.bat

Solution 4

1.Download the Gradle form gradle distribution

2.Extract file to some location

3.Open Android Studio : File > Settings > Gradle > Use local gradle distribution navigate the path where you have extracted the gradle.

4.click apply and ok

Done

EDIT 1: In the latest version of AS, the option is called "Use Gradle from: Specified location, thanks @Adam Burley for suggestion

Solution 5

Assuming this is a windows system and we are using gradle-2.1-all [Applicable to any gradle version, just change the version as we need]

All the gradles can be found in http://services.gradle.org/distributions/


Check the <Your Project>\gradle\wrapper\gradle-wrapper.properties Make sure the distributionUrl is

distributionUrl=http\://services.gradle.org/distributions/gradle-2.1-all.zip

This is enough as it will automatically download the gradle.

After doing the above stuff, if you have downloaded the zip, paste the gradle-2.1-all.zip in

C:\Users\<username>\.gradle\wrapper\dists\gradle-2.1-all\<some_hash_key>\

It will save the extra downloading time.

Share:
282,818
jackuars
Author by

jackuars

Updated on May 21, 2021

Comments

  • jackuars
    jackuars almost 3 years

    I'm using Android Studio. How can I manually install and use Gradle within Android Studio.

    I've downloaded Gradle from http://www.gradle.org/downloads version gradle-2.1-all.zip.

    When I open the zipped file I can see bin, docs etc, but I don't know where to copy it. And even after copying how to use it within Android..

  • jackuars
    jackuars over 9 years
    I am using my laptop offline, so I want to download and use from another source. Which is why am trying to do this manually.
  • jackuars
    jackuars over 9 years
    Should I define Environment variables for Gradle to get it to work? If so how?
  • Okas
    Okas over 9 years
    No, you dont need any special environment variables.
  • Larry Schiefer
    Larry Schiefer over 9 years
    Try temporarily changing the distributionUrl line to point to the zip on your filesystem, run your build (e.g. gradlew assemble) then when it is done change it to the correct URL. That should force Gradle to "download" the package from your filesystem and set it up as it expects, while leaving other machines ok when you commit the gradle directory to your VCS.
  • guicey
    guicey almost 8 years
    Thank you Lee i edited my mistake. It is indeed Ctrl+ Alt + S instead of Ctrl+ Shift + S.
  • stackdave
    stackdave almost 7 years
    after two days, i see clear with you reply, a lot of methods on the web with grep, etc, and it was simple
  • AaA
    AaA almost 7 years
    Which version of Android studio your answer applies to? in Android Studio 2.3.3 there is no Gradle under Settings Window (it is under Build, ... ) and it does not have such option as Use Local gradle distribuition
  • AaA
    AaA almost 7 years
    Read the question again! it is asking Manually! and yet your answer says automatically in an OFFLINE machine there is no way to download automatically!
  • AaA
    AaA almost 7 years
    Read the question again! it is asking Manually! and yet your answer says automatically in an OFFLINE machine there is no way to download automatically!
  • AaA
    AaA almost 7 years
    Where do you press CTRL-ALT-S? in windows explorer after extracting the files?
  • Mukesh Y.
    Mukesh Y. almost 7 years
    file->setting->Build,Execute,Deployment-> Gradle. then select Use Local gradle distribution check box and give the gradle path
  • guicey
    guicey almost 7 years
    @AaA In Android Studio / IntelliJ IDEA, this shortcut opens your IDEA settings menu. I updated your feedback thank you.
  • Seth
    Seth over 6 years
    how to get the hash key
  • Eric
    Eric about 5 years
    With android-studio 3.3, this won't work, unless you know exact hash, and put it under the hash dir.
  • Eric
    Eric about 5 years
    This works, but each time open project, android-studio will ask to confirm whether use gradlew instead. And I can't find an option to ignore that.
  • Eric
    Eric about 5 years
    @TanyavonDegurechaff Check this answer which contains more details: stackoverflow.com/a/54924485
  • ardiien
    ardiien over 4 years
    but how to set up gradle.properties then? For example, I want to add parallel property but I do not want to change gradle.properties from the team project.
  • Eric
    Eric over 4 years
    @YaroslavOvdiienko Does following answer your question: stackoverflow.com/questions/30333837/…
  • Mostafa Alayesh
    Mostafa Alayesh over 4 years
    @EricWang First you can let android studio start the download, then you stop it, and locate the file as Hackbal said, you will find the hash already created
  • Eboubaker
    Eboubaker about 4 years
    i think you have to escape the ':' with \:
  • gumuruh
    gumuruh about 4 years
    i think he is using android studio 3 and not version 2.
  • Dr Deo
    Dr Deo almost 4 years
    The option to use local gradle was there in earlier versions of android studio (version 3x) , then some bone head admin within the android team removed it in Android studio 4x.
  • Sergio Solorzano
    Sergio Solorzano over 3 years
    and how do you start android studio to download?
  • Sergio Solorzano
    Sergio Solorzano over 3 years
    where do you add this?
  • Gunaseelan
    Gunaseelan over 3 years
    In gradle-wrapper.properties.
  • Abdulla Sirajudeen
    Abdulla Sirajudeen over 3 years
    @SergioSolorzano Then Just Start Android Studio as Normal. After Build Complete it will be work
  • Adam Burley
    Adam Burley about 3 years
    In the latest version of AS, the option is called "Use Gradle from: Specified location"
  • Adam Burley
    Adam Burley about 3 years
    In the latest version of AS, the option is called "Use Gradle from: Specified location"
  • Mustafa Muawia
    Mustafa Muawia almost 3 years
    @Eboubaker thanks your notice was very usefull :)
  • Abhinav Kulshreshtha
    Abhinav Kulshreshtha about 2 years
    @AdamBurley Even though I have set "Specific Location" to my system gradle, The build logs shows it still uses inbuild gradle. Funny thing is that when I went to write gradle path, it automatically detected its location based on my system env variables. On side note, I can't find option to use system kotlin compiler in last few versions. Inbuilt compiler is slow, I remember in old version, I could use system kotlin which improved build time performance by a lot.