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

38

62

I am a greenhorn in gradle and i just tried to create a new Android Gradle Project in IntelliJ. After filling up the necessities it started to download something which took hours so i decided to force quit my IDE and open the project again.

And now I am getting this: enter image description here

And when I open the IDE logs, I see this:

2014-12-13 22:27:37,940 [103759372]   INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/Users/ramswaroop/Documents/My Workspace/PopoPics' 
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
    at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:124)
    at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:112)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter.run(DefaultBuildActionExecuter.java:46)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:177)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$300(GradleProjectResolver.java:63)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:363)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:335)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:214)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:95)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:63)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:475)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:552)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:621)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:194)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.a(ProgressManagerImpl.java:281)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:233)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$9.run(ProgressManagerImpl.java:530)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
Caused by: java.nio.channels.OverlappingFileLockException
    at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
    at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:868)
    at java.nio.channels.FileChannel.tryLock(FileChannel.java:962)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:51)
    at org.gradle.wrapper.Install.createDist(Install.java:44)
    at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:118)
    at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution$1.call(DistributionFactory.java:112)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
2014-12-13 22:27:37,941 [103759373]   WARN - nal.AbstractExternalSystemTask - Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'. 
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
    at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
    at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:401)
    at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:309)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:164)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:164)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:369)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:335)
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:214)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:95)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:63)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:475)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$2.run(ExternalSystemUtil.java:552)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:621)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:194)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.a(ProgressManagerImpl.java:281)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:233)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$9.run(ProgressManagerImpl.java:530)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)

2014-12-13 22:27:37,942 [103759374]   WARN - radle.project.ProjectSetUpTask -  
2014-12-13 22:27:37,942 [103759374]   INFO - radle.project.ProjectSetUpTask - Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'.

Consult IDE log for more details (Help | Show Log) 
 

INFO: Running on Mac Yosemite with Gradle 2.2 and IntelliJ IDEA 14 Ultimate.

Quarta answered 14/12, 2014 at 7:9 Comment(0)
G
85

It could be that the gradle-2.1 distribution specified by the wrapper was not downloaded properly. This was the root cause of the same problem in my environment.

Look into this directory:

ls -l ~/.gradle/wrapper/dists/

In there you should find a gradle-2.1 folder. Delete it like so:

rm -rf ~/.gradle/wrapper/dists/gradle-2.1-bin/

Restart IntelliJ, after that it will restart the download from the beginning and hopefully work.

Gothicism answered 8/10, 2015 at 9:35 Comment(4)
tanks, man, if help, just try to sync project again and its work, so you does not need to restart your IDE, but if necessary to restart, ok restart itMuscatel
As well as doing this, it's worth clicking the URL in the error message to check if you can download the zip file via the browser. Turns out I couldn't because of the network I was on which was blocking that URL.Revkah
It didn't work for me. I had to remove all gradle files (wrapper, daemon and caches), And then i selected the "invalidate caches and restar" optionBreadstuff
Thanks! I also tried with just a gradle sync after deleting the folder, and it worked!Taradiddle
S
32

If you are on Windows, you can go to:

C:\Users\{your_name}\.gradle

And delete all the references of the gradle package you can find in those folders:

  1. caches
  2. daemon
  3. wrapper

Then re-open your project and sync gradle

Shiksa answered 22/6, 2017 at 10:41 Comment(3)
Hi, I am getting Exception --Could not install Gradle distribution from 'services.gradle.org/distributions/gradle-5.1.1-all.zip'. I have tried with above solution but didn't worked.Please help me on this.Disturbance
Hi, no need to delete all these files, just delete C:\Users\User\.gradle\wrapper\dists\gradle-4.4-all and proceed to syncLightproof
@Disturbance Also try to Run your Android Studio as Administrator, I've spend days and hours to resolve this issue.Plainspoken
C
24

1 Close Android Studio (AS)

2 Delete the folder in C:\Users\ username \ .gradle\wrapper\dists\gradle-2.1-all

3 Run as admin

4 Sync your project files

Consuelaconsuelo answered 29/1, 2020 at 4:31 Comment(1)
I did not have that folder in the dists folder, for me it was simply to run AS as administrator.Intelligent
G
12

First check your Internet conection..

or try with

Tools -> Android -> Sync

or Try

File -> Settings -> Gradle -> Check Offline Work

enter image description here

Goda answered 14/12, 2014 at 7:19 Comment(5)
I have no option called Sync under Tools > Android in IntelliJ. And of course I am connected to internet. Did u check the logs?Quarta
I have all other options except Sync Project with Gradle FilesQuarta
Ok... can you find out any ICON of Sync ?Goda
Hey, I don't know how but my gradle started working. Anyways, thank you very much for your time. But still I haven't figured out the root cause.Quarta
I connected to internet and restart the android studio and the gradle file auto downloaded, Thanks.Proboscis
Y
6

you should also check if you are connecting via proxy. If there is a proxy set it up using File > Settings > Appearance and Behavior > System settings > HTTP Proxy

Yarkand answered 3/4, 2017 at 17:5 Comment(1)
In my case it was a proxy issue.Damages
P
6

I cannot believe the below solution, but it did solve it. in gradle-wrapper.properties file: change

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

to

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

Prytaneum answered 15/6, 2021 at 0:57 Comment(2)
Just had this issue importing an old project. Apprently, gradle discontinued their http links. In my case I was dealing with gradle-1.10-all.zipViguerie
In my case, It could not download at all. I downloaded manually and set the url as shown here pointing to a local file with file\://....Hastie
H
5

I had the same problem. (My problem is with gradle 4.4 files)

Actually the problem is incorrect downloading of 4.4 gradle which already I had. When I delete gradle 4.4 version C:\Users\$Your_User\.gradle\wrapper\dists\gradle-4.4-all

Android studio again downloads gradle-4.4 and syncs with my project.

Now it had rectified with the help of Michelin Man

Thanks for your answer Michelin

Hostelry answered 22/7, 2018 at 17:19 Comment(1)
Hi, I am getting Exception --Could not install Gradle distribution from 'services.gradle.org/distributions/gradle-5.1.1-all.zip'. I have tried with above solution but didn't worked.Please help me on this.Disturbance
J
3

https://services.gradle.org/distributions/gradle-2.1-all.zip

open this link in the browser and download the zip file and extract it to folder

Before extraction please delete the old folder whose name ends gradle-2.1-all and then you can start extracting

if you are window user extract it to this folder

C:\Users{Your-Name}.gradle\wrapper\dists

after that just restart your android studio. I hope it works it works for me .

Jacquerie answered 1/6, 2019 at 8:12 Comment(1)
Hi, I am getting Exception --Could not install Gradle distribution from 'services.gradle.org/distributions/gradle-5.1.1-all.zip'. I have tried with above solution but didn't worked.Please help me on this.Disturbance
B
3

For me, it was just close the android studio and restart as Administrator.

Beaird answered 17/11, 2020 at 13:51 Comment(0)
S
3

If all above solutions is not working and In case of your project was working fine and now getting this issue, then try this,

  • go to android studio setting.
  • select gradle under build,execution.
  • then again just set path of gradle user home (C:/Users/%user_name%/.gradle/wrapper/dists/gradle-6.5-bin)
  • just rebuild again, this helps me.
Saccharate answered 3/12, 2020 at 12:14 Comment(1)
This was the issue for me. I had a separate path which I put in there by mistake earlier. Changing gradle user home to the above path solved it for me.Bream
N
2

It could be that the corresponding Gradle version was not downloaded properly.

You could delete the broken file at

rm -rf .gradle/wrapper/dists/

and restart studio.

or try

File -> Settings -> Gradle -> Check Offline Work

and download the file from the official site and extract to the destination location

.gradle/wrapper/dists/
Nectareous answered 8/6, 2017 at 10:38 Comment(0)
J
2

In my case, the problem was that I was not connected to the same VPN with which I installed Android Studio, I do not know why it happens, but even if I have internet access, if I am not connected to the original VPN, the downloads from IDE do not work correctly.

I connected the VPN, I did the gradle again and finally it started to download and install everything correctly. I also checked that I didn't go through any proxy or anything similar in my Android configuration.

Jopa answered 27/4, 2021 at 7:23 Comment(0)
B
2

I recently had this same error, but it was due to an outbound firewall / monitoring tool silently killing the download requests in the background.

Sometimes the problem isn't Android Studio or your gradle configuration at all!

Bedwarmer answered 20/12, 2022 at 0:14 Comment(0)
T
1

In Android Studio, if you open the Design window for the app, there is error message about Gradle being not synched properly. Next to the error, there is a 'Try Again' button. If you click on that, Android studio tries to sycn up again.

That worked for me.

Tolentino answered 11/9, 2017 at 23:8 Comment(0)
C
1

In my case I had to go to

File -> Settings -> Build, Execution, Deployment -> Gradle

and then I changed the Service directory path, which was pointing to a wrong location.

Coelenterate answered 11/7, 2019 at 9:46 Comment(0)
I
1
  1. Delete .gradle data
  2. CtrlAltS then navigate to File -> Settings -> Build, Execution, Deployment -> Compiler then check "Sync project with gradle before building, if needed".

My problem was fixed with this method.

Ionization answered 24/10, 2019 at 17:8 Comment(0)
P
1

Change the distributionUrl=https://services.gradle.org/distributions/gradle-2.1-bin.zip from the Your project folder\gradle\wrapper\gradle-wrapper.properties to new one.

Preprandial answered 6/4, 2021 at 16:17 Comment(0)
D
1

what worked for me is

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

enter image description here

Didynamous answered 31/5, 2022 at 6:37 Comment(0)
A
0

One more reason for this error (assuming that gradle properly setup) is incompatibility between andorid.gradle tools and gradle itself - check out this answer for the complete compatibility table.

In my case the error was the same as in the question and the stacktrace as following:

java.lang.NullPointerException
    at java.util.Objects.requireNonNull(Objects.java:203)
    at com.android.build.gradle.BasePlugin.lambda$configureProject$1(BasePlugin.java:436)
    at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
    ...

I've fixed that by upgrading com.android.tools.build:gradle to the current latest 3.1.4

buildscript {
    repositories {
        ...
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
    }
}

Gradle version is 4.6

Abba answered 26/8, 2018 at 15:37 Comment(0)
B
0

I was facing the same problem in IntelliJ. It was working from command line though.

I found the issue was because of an improper Gradle config in the IDE. I wasn't using the "default Gradle wrapper" as recommended:

enter image description here

Blatt answered 18/6, 2019 at 16:7 Comment(0)
C
0

On MAC Remove gradle-2.1-all folder from the following path /Users/amitsapra/.gradle/wrapper/dists/gradle-2.1-all and then try gradle build again. I faced same issues with 5.4.1-all.

It takes a little time but fixes everything

Clementclementas answered 4/9, 2019 at 5:17 Comment(0)
C
0

For me, the reason is that the gradle.zip IDE downloaded is broken (I cannot uncompress it manually), and following steps help.

  1. gradle sync, and it says could not install from ${link}, ${gralde.zip} ...
  2. download from ${link} manually
  3. go to the ${gradle.zip}'s location
  4. replace the ${gradle.zip} with the one downloaded, remove the .lck file on the same path.
  5. gradle sync.

Note:

  • ${link} is something like https://services.gradle.org/distributions/gradle-4.6-all.zip
  • ${gradle.zip} looks like ~/.gradle/wrapper/dists/gradle-${version}-all/${a-serial-string}/gradle-${version}-all.zip
Chirrup answered 9/12, 2019 at 7:16 Comment(0)
C
0

I have also recieved this issue inside of InteliJ.

Go to the gradle/wrapper folder and modify distributionUrl inside of gradle-wrapper.properties to a correct version.

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Cuspidation answered 5/6, 2020 at 0:5 Comment(0)
A
0

It also disturb me a lot but now it is fine The solution is very simple (written blow) [window (android studio)]

  1. go to C:\Users\your user name.gradle
  2. open wrapper/dists and delete the folder that is distrubing you in my case --gradle-6.5--
  3. then go back to .gradle folder and this time open daemon folder and delete the folder with same number that is disturbing you in my case --6.5--
  4. Then again go back to .gradle folder and this time open caches folder and delete the folder with same number that is disturbing you in my case --6.5--
  5. now if your android studio is open then close it and again start it but this time with administrator mode by right clicking on the icon of android studio icon it is important
  6. you should have internet connection and now your android studio will setup every thing by its own (please don't distrub it while it is doing its operation)
Averment answered 26/11, 2020 at 12:1 Comment(0)
M
0

I solve it by downloading zip file from https://services.gradle.org/distributions/gradle-2.1-all.zip manually, put it inside C:\Users\<username>\.gradle, and sync.

Myrtismyrtle answered 11/3, 2021 at 13:56 Comment(0)
T
0

(Only for Mac Users) download the gradle file from the link and then close the project then at the front page ,under the creat project option there is option called Import project(Gradle,Eclipse ADT,etc) here you have to select the gradle file which you have downloded earlier . Then restart the Android studio .....hope your problem is solved now

Tarrasa answered 20/3, 2021 at 21:28 Comment(0)
C
0

In my case I solved the problem with

  1. Ctrl + Shift+ F
  2. Type 2.1 or just type the version of the gradle that can't be installed
  3. replace the version of gradle with the correct one in the gradle-Wrapper.properties File in my case I replaced it with 6.1.1
Chargeable answered 24/3, 2021 at 9:45 Comment(0)
B
0

Guys In my case the gradle is not properly install thats why this issue is happan with me.

Resolution:

  1. Go to User Directory
  2. Then Go to .gradle\wrapper\dists
  3. Remove the folder which you are facing error
  4. Invalidate cache and restart your android studio
Border answered 20/5, 2021 at 5:35 Comment(0)
T
0
  1. Download directly from Gradle: https://services.gradle.org/distributions/ Choose the relative version, pay attention to the name behind the version
  2. Open the folder as shown enter image description here You can delete the contents in the wrapper folder before, replace it with the Gradle file you just downloaded, and unzip it. After unzipping, you can delete the compressed file.
  3. Open Gradle settings. Modify the path problem, and then synchronize it. There should be no problem
Teletype answered 3/6, 2021 at 11:36 Comment(0)
R
0

Here is what worked for me on windows 10.

Close my project. Close Android Studio. Run Android Studio. Open project.

Android studio takes a few minutes while everything sorts itself out.

I thought that maybe Android Studio just needed sufficient rights to extract and put the files in all the right locations and possibly set the path variables.

Rede answered 9/7, 2021 at 5:49 Comment(0)
B
0

Add username and password in distributionUrl:

distributionUrl = https://username:[email protected]/vdca-mobile-maven/gradle-5.4.1-all.zip

Note: no need to encoded base64 for either username or password.

TL:DR

I encountered the issue when I tried to download gradle in android studio from our custom maven artifactory.

It forbids 'anonymous' access of artifacts in Artifactory

This initiative aims to disable 'anonymous' access of artifacts in Artifactory and enforces users to authenticate to read any artifact from Artifactory. This is done for obvious security reasons and to create an audit trail for artifacts accessed.

I can verify it when I open logs of Android Studio idea.log (Help -> Show log in Finder)

2021-09-08 16:05:46,759 [2335097]   INFO - .project.GradleProjectResolver - Gradle project resolve error 
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://artifactory.trusted.visa.com/vdca-mobile-maven//gradle-5.4.1-all.zip'.
    at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution.getToolingImplementationClasspath(DistributionFactory.java:139)
    at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:41)
    at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:44)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:104)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:86)
    at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
    at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:61)
    at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor.lambda$run$0(DefaultAsyncConsumerActionExecutor.java:55)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://artifactory.trusted.visa.com/vdca-mobile-maven/gradle-5.4.1-all.zip
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
    at org.gradle.wrapper.Download.downloadInternal(Download.java:78)
    at org.gradle.wrapper.Download.download(Download.java:63)
    at org.gradle.tooling.internal.consumer.DistributionInstaller$1.run(DistributionInstaller.java:128)

After I add the username and password, I can see the log:

2021-09-08 16:44:56,253 [ 346318]   INFO -                         STDOUT - Downloading https://artifactory.trusted.visa.com/vdca-mobile-maven/gradle-5.4.1-all.zip 
2021-09-08 16:44:56,215 [ 346280]   INFO - e.project.sync.GradleSyncState - Started single-variant sync with Gradle for project 'VMCP'. 

Gradle is downloaded to here.

WM-C02WM0T3HTD8:vdca_android_20_10_08_pr zgong$ ls -la ~/.gradle/wrapper/dists/gradle-5.4.1-all/2oog0xj75bs1j4pttjqi636mc/
total 260960
drwxr-xr-x   6 zgong  VISA\Domain Users        192 Sep  8 16:46 .
drwxr-xr-x   5 zgong  VISA\Domain Users        160 Sep  8 16:44 ..
drwxr-xr-x  12 zgong  VISA\Domain Users        384 Sep  8 16:46 gradle-5.4.1
-rw-r--r--   1 zgong  VISA\Domain Users  132768903 Sep  8 16:46 gradle-5.4.1-all.zip
-rw-r--r--   1 zgong  VISA\Domain Users          0 Sep  6 16:17 gradle-5.4.1-all.zip.lck
-rw-r--r--   1 zgong  VISA\Domain Users          0 Sep  8 16:46 gradle-5.4.1-all.zip.ok

BTW, this way below does not work for me

Using system properties can be done in the .gradle/gradle.properties file in the user’s home directory

Specifying the HTTP Basic Authentication credentials using system properties

systemProp.gradle.wrapperUser=username
systemProp.gradle.wrapperPassword=password

Reference: https://docs.gradle.org/current/userguide/gradle_wrapper.html

Burnejones answered 8/9, 2021 at 9:2 Comment(0)
P
0

For the peeps that are using Ionic/Cordova, remove node_modules, platforms, and plugins folders

rm -rf node_modules platforms plugins

Re-install everything

npm i && ionic cordova platform add android

After that open platforms/android/project.properties file

It was like this for me

target=android-29
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.billingclient:billing:3.0.0
cordova.system.library.2=com.google.android.gms:play-services-analytics:+
cordova.system.library.3=com.android.installreferrer:installreferrer:2.1
cordova.system.library.4=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.5=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.6=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.7=com.google.android.gms:play-services-analytics:11.0.1
cordova.system.library.8=androidx.annotation:annotation:1.1.0
cordova.system.library.9=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.10=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.11=androidx.legacy:legacy-support-v4:1.+
cordova.system.library.12=androidx.appcompat:appcompat:1.+
cordova.system.library.13=com.onesignal:OneSignal:3.16.0
cordova.gradle.include.1=onesignal-cordova-plugin/MyApp-build-extras-onesignal.gradle

Remove all duplicates and everything that targets version:+, so the file looked something like this afterward

target=android-29
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.billingclient:billing:3.0.0
cordova.system.library.3=com.android.installreferrer:installreferrer:2.1
cordova.system.library.4=androidx.legacy:legacy-support-v4:1.0.0
cordova.system.library.7=com.google.android.gms:play-services-analytics:11.0.1
cordova.system.library.8=androidx.annotation:annotation:1.1.0
cordova.system.library.12=androidx.appcompat:appcompat:1.0.0
cordova.system.library.13=com.onesignal:OneSignal:3.16.0
cordova.gradle.include.1=onesignal-cordova-plugin/Artinove-build-extras-onesignal.gradle

Build your project

ionic cordova build android

And all should work then.

Persist answered 1/10, 2021 at 13:13 Comment(0)
C
0
  1. Go to the project gradle folder --> gradle-wrapper.properties

  2. change the distributionUrl to another(you can found this in your .gradle\wrapper\dists folder)

  3. Click Sync now

enter image description here

enter image description here

Caputo answered 14/11, 2021 at 16:55 Comment(0)
B
0

Try to remove the wrapper, daemon and caches files in C:\Users\{userName}\.gradle and the in your Android Studio select the option File/Invalidate caches and restart And that's all!!! It worked for me!!

Breadstuff answered 5/3, 2022 at 18:29 Comment(0)
J
0

I download from the link and locate the gradle to specified location in dowloaded gradle folder

Hope it help :)

enter image description here

Jessamyn answered 15/4, 2022 at 16:7 Comment(0)
F
0

Method 1:-

go to:

C:\Users{your_user_name}.gradle

And go to each folder and check that your gradle(gradle-x.x-all)

which mentioned in the error exists, delete all the references Gradle package from all folders.

Then open Android Studio as "Run As Admin"

Method 2:-

go to error message link and download mentioned gradle : https://downloads.gradle-dn.com/distributions/gradle-x.x.x-bin.zip

after that extract in .gradle\wrapper\dists and open Android studio again but as "Run As Admin"**

Furiya answered 8/5, 2022 at 7:49 Comment(0)
B
0

Using a VPN fixed it for me.

After trying most of the already given solutions, 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.

Bashan answered 7/3 at 14:51 Comment(0)
W
-1

I dont know if it will help anyone else, But after working through each answer and none of them working a full re install of android studio did the trick for me.

Wallow answered 13/1, 2022 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.