Android Gradle's dependency cache may be corru

2019-04-27 00:54发布

问题:

I am trying to import this project, even I tried to import other few projects too, I am getting below error.

https://github.com/ashdavies/data-binding

I have spent my 5 hours on it, even I tried many solutions on google but nothing gonna worked for me.

I tried following solutions, nothing worked.

1) delete .gradle directory
2) Restart IDE, 
3) I tested with com.android.tools.build:gradle-experimental:0.7.0-alpha1

I am frustrated because of this Gradle and these issues.

Gradle Version : Gradle-2.13, I do not want to change this version.
Android Studio Version : Stable 2.1.1

Note : My other project is working fine and I can build it too.

Please help me if anybody faced the same problem.

Thanks

回答1:

You can try different workarounds for this problem :

1- Clean project and Rebuild it.

2- Before importing the project, remove the contents of the Build folders.

Then replace the contents of your gradle-wrapper.properties file with the following lines, to make it use a local distribution for building the project :

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=file\:/opt/gradle/gradle-2.13-all.zip

in which, the last line prevents android studio to download or use a corrupted gradle cache.



回答2:

Because your gradle path for project is incorrect. Go to ->Settings ->Gradle

and select "use default gradle settings" and than sync project. and issue will be resolved.



回答3:

In my case, it was happening because i haven’t set the JDK path in environment variable. Please check from your Android studio studio that your JDK path is correct.

Go to Project Structure> SDK Location and check JDK Path. Give it the correct JDK path and also set the JAVA_HOME environment variable.



回答4:

You can try this solution as i was facing this issue showing Error2 Gradle's dependency cache may be corrupt and gradle build not working and resolved it. Already answered this question on stack. You can reffer to this answer link

It includes firstly downloading latest graddle version from official site then replacing that unzipped file with home/yourUser/.graddle/wrapper/dists containg older version file on Mac.



回答5:

  1. Go to any browser

  2. type gradle and press enter

you can specify any version you want after the

gradle keyword

i am downloading gradle 3.3

  1. https://services.gradle.org/distributions click on this link which is in description directly if you want

  2. click on gradle 3.3 all.zip

  3. wait for the download to complete

  4. once the download is complete extract the file to the location

c://user/your pc name /.gradle/wrapper/dists

  1. wait till extraction it takes 5 mins to complete

  2. Now open your project in android studio

9.go to file > settings >bulid ,exec,deployment > gradle

  1. now change use default gradle to

use local gradle distributn

select the location where you had extracted gradle 3.3.zip

C:\Users\your pc name.gradle\wrapper\dists\gradle-3.3

  1. click on OK

  2. Now build starts again and

you can see now the build is successful and error is resolved

or

watch tutorial https://www.youtube.com/watch?v=u92_73vfA8M