3

Error:Failed to open zip file. Gradle dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:support-v4:23.2.0'
}
Cœur
  • 32,421
  • 21
  • 173
  • 232
Mahesh Kumthekar
  • 53
  • 1
  • 1
  • 5
  • check this http://stackoverflow.com/a/39821915/5188159 – Charuක Jan 22 '17 at 10:28
  • 1
    Possible duplicate of [Error:Failed to open zip file. Gradle's dependency cache may be corrupt](https://stackoverflow.com/questions/42652980/errorfailed-to-open-zip-file-gradles-dependency-cache-may-be-corrupt) – Cœur Aug 22 '17 at 10:54
  • check this answer https://stackoverflow.com/a/43801113/7120475 – Hamid Asghari Apr 03 '18 at 05:26
  • Please check this answer: https://stackoverflow.com/questions/54304945/gradles-dependency-cache-may-be-corrupt-this-sometimes-occurs-after-a-network/54305292#54305292 – Ajay Nishad Jan 23 '19 at 20:10

5 Answers5

14

I faced the same issue when I updated my android studio to 2.2.3 from 2.1. After a while of struggling, went project->right click -> open module settings->project

1) Gradle : 2.14.1
2) Android plugin version : 2.2.3
3) Android plugin repository : jcenter
4) Default library repository : jcenter

OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
5

Repair Gradle Installation

(From my answer at https://stackoverflow.com/a/43801113/7120475)

This usually happens when something goes wrong in Android Studio's first launch (eg. system crash, connection loss or whatever).

To resolve this issue close Android Studio and delete the following directory's content, necessary files will be downloaded on IDE's next launch.

macOS: ~/.gradle/wrapper/dists

Windows: C:\Users\your-username\.gradle\wrapper\dists

While downloading Gradle manually works, I recommend letting Android Studio itself to do it.

Hamid Asghari
  • 4,954
  • 3
  • 20
  • 32
  • Thanks Hamid :) for fixing "Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)" your answer is the perfect solution, thanks – Javeed Ishaq Jan 16 '21 at 03:26
1

Hey not necessary to set gradle manually. i have also faced this issue but i deleted all files in gradle folder path "C:/Users/username/.gradle/" simple steps follow

  1. first goto path "C:/Users/MickeyMouse/.gradle/"
  2. delete all files in above path.
  3. List item open android studio and sync gradle or build again or create new project.
  4. List item it will be auto downloaded new gradle version files and auto build.

*Make sure you your gradle settings like this - checked "Use default gradle wrapper(recommended) - unchecked offline work

0

Mine worked after I added my NDK path in Android Studio.

File -> Project Structure -> SDK Location -> Android NDK Location

Sanket B
  • 954
  • 1
  • 8
  • 22
0

Hard and fast solution for MacOS (and possibly Linux)

  1. Go to ~/.gradle
  2. Delete all files: rm -rf .gradle
  3. Go to your project folder and do : ./gradlew bootRun

The last step should download all gradle dependencies again.

Meghajit
  • 21
  • 1