9

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.

Zoe
  • 27,060
  • 21
  • 118
  • 148
sam_k
  • 5,983
  • 14
  • 76
  • 110
  • Can you try to delete your home gradle cache directory, on mac it is ~/.gradle/caches – Anuj Jun 25 '16 at 08:56
  • @basilisk : I did that too, Even same project is giving error on my other laptop too and my friend also get the same error. – sam_k Jun 25 '16 at 16:00
  • Completely remove the ~/.gradle and yourproject/.gradle directories maybe? – Anuj Jun 26 '16 at 04:20
  • Possible duplicate of [Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)](http://stackoverflow.com/questions/38442901/gradles-dependency-cache-may-be-corrupt-this-sometimes-occurs-after-a-network) – AdrianHHH Jan 20 '17 at 10:14

8 Answers8

5

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.

Farhad
  • 12,178
  • 5
  • 32
  • 60
1
  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

Manoj Selvin
  • 2,247
  • 24
  • 20
1

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

Ajji
  • 3,068
  • 2
  • 30
  • 31
0

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.

Community
  • 1
  • 1
Ali Nawaz
  • 2,016
  • 20
  • 30
  • 1
    Welcome to Stack Overflow! A link to a potential solution is always welcome, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. Take into account that being barely more than a link to an external site is a possible reason as to Why and how are some answers deleted? – afxentios Jan 23 '17 at 09:32
0

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.

Developine
  • 12,483
  • 8
  • 38
  • 42
0

delete .gradle, .idea and gradle folder from the project and then invalidate cache and restart. problem will be resolved. Thanks :)

0

Sometimes it's a cache issue and sometimes due to interruption in download.

Step 1:

Try to download gradle distribution manually https://services.gradle.org/distributions/

and then go to project settings -> gradle -> and use the file which you've downloaded

Step 2:

If step#1 still not working, then it may be a cache issue. If you are a mac user, go to your finder user folder, show hidden items by pressing [Command + Shift + .] , Go to gradle folder and

Hamza Khan
  • 1,433
  • 13
  • 19
-1

In my case is that gradle-5.1.1-all.zip download failed, so I go to zipStoreBase+zipStorePath(configured in gradle-wrapper.properties, eg: E:\gradle-home\wrapper\dists), and delete the gradle-5.1.1-all directory, and let android studio to download that zip file again.

Brave Dolphin
  • 154
  • 1
  • 4