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

25

31

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 a new project the above exception occurred. I have searched on Google regarding the above error but none resolved.

Below are the links that I have tried but none worked

Is this an issue with Antivirus which is installed on the local machine? Or I am just guessing its because of the Antivirus?

I have been trying this for 3 days. Please help me with this.Any help would be appreciated.

Monophthong answered 22/8, 2019 at 16:3 Comment(2)
what is the error message? have you checked your proxy?Buss
I cannot see Logcat.I am getting only above message, once we start Android studio.Proxy ?Monophthong
P
47

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!

Pilkington answered 27/11, 2019 at 15:27 Comment(3)
How do I run Android Studio as an administrator on Mac?Isosceles
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.Rebutter
add sudo at start of command in mac terminal. e.g. sudo npx react-native run-androidDarbydarce
D
35

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.
Dacha answered 20/12, 2019 at 5:31 Comment(0)
P
24

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.

Prelacy answered 12/6, 2021 at 11:41 Comment(6)
it does not seems but it is the solution, I have done this in gradle-wrapper. By default studio given a blocked url. you just need to remove backward slash as given after https as I mentioned in the answer.Prelacy
yes, it works perfectlyBlondell
thanks a million, after spending 1+ month struggling with this issue finally found the answer!Experimental
worked a treat!Amalamalbena
Brilliant, I was just about to give up until I tried this. Worked perfectly thanks.Mcclinton
Whiskey Tango Foxtrot - why would the gradle-wrapper.properties be messed up like that?Alodium
B
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'
        ...
    }
}
Buss answered 23/8, 2019 at 15:31 Comment(5)
Thanks for your response.I have tried above solution before but didn't worked.Any other options please ?Monophthong
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.Wendelina
I am only getting above exception when I start a new project or Import any project, I cannot see logcat too.Monophthong
To get latest version, create a new project and take refer build.gradle (project) and gradle-wrapper.propertiesRadiobiology
when creating a new project, it will automatically download too, if you are facing issues with old projects.Radiobiology
L
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.

Legerdemain answered 19/11, 2020 at 8:44 Comment(1)
Plugin [id: 'com.android.application', version: '8.0.0', apply: false] was not found in any of the following sources:Holdup
A
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.

Amatol answered 27/8, 2019 at 13:14 Comment(3)
Hi ditn, Thanks for your response. Can you be more specific please ?Monophthong
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.Amatol
I am not sure but I have tried almost all possible cases, but no luck.Monophthong
P
2

Check if you accidentally changed Gradle user home path. Go to Preference in Android studio, search for gradle and check for the gradle user home path.

It should be like:

/Users/mac/.gradle/
Personally answered 16/2, 2022 at 5:18 Comment(0)
P
1

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

Pulchia answered 16/1, 2020 at 12:39 Comment(0)
A
1

Download Gradle 5.4.1 manually from https://downloads.gradle-dn.com/distributions/gradle-5.4.1-all.zip and extract the contents to .gralde directory within your android project. Post which, restart the android studio.

Artificer answered 21/1, 2020 at 9:59 Comment(0)
C
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.

Crumley answered 1/4, 2020 at 18:9 Comment(0)
P
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
Punctuality answered 21/10, 2021 at 4:3 Comment(0)
B
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://mcmap.net/q/458763/-could-not-install-gradle-distribution-from-39-https-services-gradle-org-distributions-gradle-5-4-1-all-zip-39 ,

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.

Brien answered 27/1, 2022 at 7:42 Comment(0)
A
1

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.

Ablate answered 20/2, 2023 at 8:22 Comment(0)
R
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

Reductive answered 27/10, 2020 at 23:33 Comment(0)
M
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.

Micaelamicah answered 10/6, 2021 at 12:0 Comment(0)
G
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/

Gallo answered 23/8, 2021 at 4:7 Comment(0)
H
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

Homegrown answered 28/11, 2021 at 23:33 Comment(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 How to Answer.Reeves
V
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.

Veradia answered 4/8, 2022 at 10:25 Comment(0)
T
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

Tasty answered 7/11, 2022 at 2:45 Comment(0)
S
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.

Sacramentalist answered 14/8, 2023 at 14:21 Comment(0)
I
0

Using a VPN fixed it for me.

After I tried most of the solutions above, I tried downloading that specific version manually from the release page(https://services.gradle.org/distributions/), but I got an error. Checking the console, it was a 401(unauthorized) error.

I downloaded Proton VPN, used the free account and the default location (Netherlands) and retried downloading from the release page, it worked and I retried in Android studio and it was a success.

Inward answered 7/3 at 6:56 Comment(0)
T
0

For me, the issue was that Android Studio wasn't detecting the proxy I was behind. I kept getting the Untrusted Certificate popup every time I launched Android Studio, regardless of how many times I accepted - and then eventually hit the error "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5..-all.zip'"

I configured the HTTP proxy in Android Studio (Settings ->Appearance & Behavior ->System Settings->HTTP Proxy) and set automatically accept certificates to true (Settings->Tools->Server Certificates->Accept Non Trusted Certificates Automatically). However, be careful trusting all untrusted certificates - this has potential security risks associated with it. I was fine in my case as the certificate issuer was always the same.

I could download and install gradle after that.

Trager answered 1/4 at 12:7 Comment(1)
Refer to this answer to add your certificate to Android Studio: https://mcmap.net/q/382664/-untrusted-server-certificate-in-intellijTrager
S
-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

Syndesis answered 4/6, 2021 at 10:54 Comment(0)
B
-1

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

Borzoi answered 29/5, 2022 at 15:13 Comment(0)
T
-1

In my case, changing my network solved the problem.

Thready answered 25/4 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.