26

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'

I have just installed Android Studio 3.5 on windows and then created new project then above exception occurs. I have searched on google regarding the above error but none resolved.

Below are the links which I have tried but none worked

Is this issue is with Antivirus which is installed in local machine ?.I am just guessing, is this because of Antivirus ?

I was trying with this since 3 days.Please help me on this.Any help would be appreciated.

Naveen
  • 814
  • 2
  • 9
  • 22

22 Answers22

43

I had the same problem and eventually I figured out that running Android Studio as administrator solves it. You can at least give it a try!

Irina Cososchi
  • 431
  • 4
  • 3
  • 4
    How do I run Android Studio as an administrator on Mac? – Rohit Singh Jul 23 '21 at 04:47
  • To always run as Administrator, right-click the Android Studio shortcut on the Start menu, click on "More", then "Open File Location", and the file explorer will pop up. Right-click the Android Studio shortcut on the file explorer, go to "Properties", on the properties dialog click on "Advanced" (down there, close to the bottom), and finally, check the "Run as Administrator" checkbox and confirm everything. Just like that, every time you run Android Studio through that shortcut it'll run as Admin. – Junior Damacena Jul 15 '22 at 21:56
  • add sudo at start of command in mac terminal. e.g. sudo npx react-native run-android – Ateş Danış Oct 06 '22 at 07:26
34

Steps to fix:

  1. Close Android studio.
  2. Right click on launcher icon of Android Studio
  3. Click on "Run as administrator"
  4. It will run like charm.
Edric
  • 24,639
  • 13
  • 81
  • 91
Ananta Prasad
  • 3,655
  • 3
  • 23
  • 35
21

Goto gradle-wrapper and see carefully the URL distributionUrl=https \ ://services.gradle.org/distributions/gradle-6.1.1-all.zip

now correct the https \ :// to https:// and click on "try again upside."

it will took download the file and run automatically. And after successful run promote thi$ answer.

Aarif Husain
  • 424
  • 5
  • 8
6

Open your gradle-wrapper.properties and modify your distributionUrl to point to gradle-5.4.1-all.zip, i.e.

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

Change classpath to 3.5.0

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        ...
    }
}
shizhen
  • 12,251
  • 9
  • 52
  • 88
  • Thanks for your response.I have tried above solution before but didn't worked.Any other options please ? – Naveen Aug 23 '19 at 15:38
  • 1
    what happened when you did this, what error do you get? this is how it should work, if it fails, you have to give us more information about how it failed. – Martin Marconcini Aug 26 '19 at 11:37
  • I am only getting above exception when I start a new project or Import any project, I cannot see logcat too. – Naveen Aug 27 '19 at 13:35
  • To get latest version, create a new project and take refer build.gradle (project) and gradle-wrapper.properties – Reejesh Jul 09 '21 at 09:58
  • when creating a new project, it will automatically download too, if you are facing issues with old projects. – Reejesh Jul 29 '21 at 07:09
3
  1. Close your Android Studio, whatever version you are using.
  2. Start it again with administrative log in.
  3. Android Studio will detect what needs to be updated or downloaded.

Automatically it will resolve the issue.

Elletlar
  • 3,136
  • 7
  • 32
  • 38
  • Plugin [id: 'com.android.application', version: '8.0.0', apply: false] was not found in any of the following sources: – CS QGB May 06 '23 at 21:55
2

5.5.1 is out now, try upgrading to that using ./gradlew wrapper --gradle-version=5.5.1 and see if that makes a difference. This is preferable to editing any Gradle files manually.

ditn
  • 1,386
  • 1
  • 10
  • 23
  • Hi ditn, Thanks for your response. Can you be more specific please ? – Naveen Aug 27 '19 at 13:17
  • 1
    Sure, run this command in the `terminal` tab in Android Studio. It'll attempt to fetch the latest version of the Gradle wrapper and install it. – ditn Aug 27 '19 at 13:21
  • I am not sure but I have tried almost all possible cases, but no luck. – Naveen Aug 27 '19 at 13:26
1

For me, i re-downloaded the new and latest version of android studio, installed it full. that solved the problem for me.

N-Alli
  • 11
  • 1
1

download gradle 5.4.1 manually from https://downloads.gradle-dn.com/distributions/gradle-5.4.1-all.zip and extract the file and please it in .gralde file in your android project. then restart the android studio

1

In case the complete error message is something like:

Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'.
error in opening zip file

You need to delete two files( under your .gradle/wrapper/dists/* directory):

  • gradle-5.4.1-all.zip
  • gradle-5.4.1-all.zip.lck

Then try again to download dependencies or upgrade.

Estuardolh
  • 111
  • 1
  • 6
1

Sometimes it might be due to the broken files in .gradle file.

This is an hidden folder in installation directory. Remove the dists folder from this location and go to File -> Invalidate Caches/Restarts.

For me it helped.

rm -rf .gradle/wrapper/dists
atline
  • 28,355
  • 16
  • 77
  • 113
1

I got the same issue in new "Android Studio Bumblebee | 2021.1.1" release. Like "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-gradle-7.2-all.zip'".

I did the following steps,

Step 1:

I did the same steps mentioned here- https://stackoverflow.com/a/59420289/1122622 ,

Like,

  1. Close Android studio.
  2. Right click on launcher icon of Android Studio
  3. Click on "Run as administrator".

Step 2:

Also, verified with official gradle URL- https://services.gradle.org/distributions/ , the given link was right or wrong.

Step 3:

Don't forget to restart the Android Studio once the gradle download was completed.

After all the above 3 steps your issue will be resolved for sure and it will be applicable for upcoming gradle upgrade issue.

Note: Also verify "Do not build Gradle task list during Gradle sync" is enabled, in File->Settings->Experimental->Gradle.

Nandha
  • 253
  • 2
  • 10
1

Check if you accidently changed Gradle user home path. Goto Preference in Android studio, search for gradle and check gradle user home path.

It should be like:

/Users/mac/.gradle/

Sagar Yadav
  • 137
  • 2
  • 11
0

From: classpath 'com.android.tools.build:gradle:3.2.1'

To: classpath 'com.android.tools.build:gradle:3.5.0'

And the gradle version:

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

GL

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62
0

I got this error while opening a very old project, the reason was that it was trying to fetch over http and not https. Update the distributionUrl path to https in the path \<project directory\>\gradle\wrapper\gradle-wrapper.properties and run the android studio in admin mode.

kapkhanna
  • 1
  • 1
0

Please check the value of checksum that you are using in the 'gradle-wrapper.properties' for the version that you are using. It could also be a problem and you get the same error.

Find the value of checksum for the gradle versions at below link:

https://gradle.org/release-checksums/

Giri
  • 14
  • 1
0

1-Create new project on android studio 2-open the new project gradle-wrapper.properties 3-copie the new distributionUrl 4-paste it on your own project 5-click on try again this will correct error

  • 1
    Welcome to Stack Overflow. This question is over two years old and has 17 existing answers. What _new_ information does this answer provide? Please read [answer]. – ChrisGPT was on strike Nov 29 '21 at 01:16
0

My solution is just turn on the offline mode, and give the wrong version value like "https://services.gradle.org/distributions/gradle-7.2.1-all.zip", it shows the error like no offline package available and asks me to try in offline mode, then just replace with the exact correct value and turn off the offline mode, then click try again, it is worked for me.

Merbin Joe
  • 611
  • 6
  • 27
0

Change this distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip to distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip

Then click file, in the dropdown click invalidate Caches

0

Worked for me these steps

Goto->

gradle-wrapper.properties

Update this (backward slash after https) distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip

to distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip

and Sync the project or click on "try again" option appearing on top

and restart the Android studio, it will automatically download required files.

harry
  • 171
  • 1
  • 4
0

Try downgrading the gradle version in gradle-wrapper.properties.

In my case I pulled a commit from our github project not knowing that my colleague has upgraded his own gradle version. I had to downgrade the version to the older one I was using before it started working.

Try it and see if it helps.

-1

Just find gradle-wrapper.properties in your IDE. And change version in distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip' to distributionUrl=https://services.gradle.org/distributions/gradle-6.8.3-bin.zip

-1

Ensure the Network connection is very good and keep on retrying. Sometimes i tap retry few times before it works.

Akinyemi Jamiu
  • 431
  • 3
  • 10