Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle's dependency cache may be corrupt and gradle build not working

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

enter image description here

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.

like image 611
sam_k Avatar asked Jun 25 '16 08:06

sam_k


3 Answers

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.

like image 160
Farhad Faghihi Avatar answered Nov 08 '22 06:11

Farhad Faghihi


  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

like image 26
Manoj Selvin Avatar answered Nov 08 '22 06:11

Manoj Selvin


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.

enter image description here

like image 1
Ajji Avatar answered Nov 08 '22 06:11

Ajji