I\'m using Android Studio. How can I manually install and use Gradle
within Android Studio
.
I\'ve downloaded Gradle
from http
Assume, you have installed the latest gradle once. But, If your particular project gradle version not match with the gradle version that already installed in the machine, the gradle sycn want to download that version. To prevent this download there is one trick. First You have to know the gradle version that already installed in your machine. Go to : C:\Users{username}.gradle\wrapper\dists, here you see the versions allready installed, remember the latest version, assume it is gradle-6.1.1-all.zip . Now, come back to Android Studio. In your Opened project, navigate Android Studio's project tree, open the file gradle/wrapper/gradle-wrapper.properties. Change this entry:
distributionUrl=http\://services.gradle.org/distributions/gradle-6.1.1-all.zip
This way we prevent downloading the gradle again and again. But avoid this thing, if the version really old. If that, you will find this warning :
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
(There are 2 solutions mentioned in existing answers that might work, but the preferred one - manually download gradle for gradlew
, is lack of essential details, and cause it fail. So, I would add a summary with missing details to save the unnecessary time wasted, in case others encounter into the same issue.)
There are 2 possible solutions:
Solution A: Use location gradle
, and delete gradlew
related files. (not recommend)
Refer to this answer from this post: https://stackoverflow.com/a/29198101/
Tips:
Solution B: Download gradle
distribution manually for gradlew
. (recommended)
Android Studio will download gradle to sub dir named by a hash.
To download manually, need to download to the exact sub dir named by the hash.
Steps:
.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/
ps -aux grep | android
.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/
gradle-4.10.1-all.zip.part
*.part
file..gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/gradle-4.10.1-all.zip
Android Studio
and try again.
.gradle/wrapper/dists/gradle-4.10.1-all/455itskqi2qtf0v2sja68alqd/gradle-4.10.1/
Tips:
Android Studio
& creating blank project again, if you see it says waiting for other process to download the distribution.Android Studio
might use different gradle
version, thus might need to repeat this process once, when Android Studio
is upgraded.BTW:
Here is the dir layout on my Linux
(For Android Studio 3.3.1
, which use gradle
4.10.1)
eric@eric-pc:~/.gradle/wrapper
$ tree -L 4
. └── dists └── gradle-4.10.1-all └── 455itskqi2qtf0v2sja68alqd ├── gradle-4.10.1 ├── gradle-4.10.1-all.zip ├── gradle-4.10.1-all.zip.lck └── gradle-4.10.1-all.zip.ok
Suggestions to Android-Studio
Android Studio
.gradle
installation dir or .zip file to be used by gradlew
.Go to the download https://gradle.org/ and download the latest zip file (currently 3.1 is the latest version)
Extract the downloaded zip file into /opt/android-studio/gradle/.
Open your project in Android Studio and hit Ctrl + Alt + S
Search for Gradle in the Search bar of the setting window
Select: (X) Use local gradle distribution and set Gradle home to /opt/andriod-studio/gradle/gradle.x.x (where x.x is the vesrion of the gradle zip file you just downloaded.). Then click on apply.
Try to sync Gradle again if the sync has already failed.If not close your project and reopen your project.
Hope this solves your problem.
download the desired pacakge Then modify the distribution line to
distributionUrl=file:/c:/Gradle/gradle-5.5.1-all.zip
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
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\