5

When I open Project it will give error:

Error:Failed to open zip file. Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)

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

but not working for me.

this is my build.gradle file:

apply plugin: 'com.android.application'

android {
     compileSdkVersion 26
     buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.web"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
      compile 'com.android.support:appcompat-v7:26.0.1'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
allprojects {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com'
    }
    maven { url "https://jitpack.io" }

}

Top Level Build File (Project Level)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()

        flatDir {
            dirs "${rootDir}/libs"
        }
    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}
5377037
  • 9,493
  • 12
  • 43
  • 73
Learning Always
  • 1,474
  • 2
  • 20
  • 39

4 Answers4

1

According to the solution here:

  • Close Android Studio.

  • Download Gradle 3.3 binary from https://services.gradle.org/distributions/gradle-3.3-bin.zip

  • Extract the downloaded zip file to the gradle folder:

      C:\Users\user-name\.gradle\wrapper\dists\
    
  • Now open the Android Studio, go to File -> Settings -> Build, Execution, Deployment -> Gradle and set Gradle Home to the folder gradle-3.3 and SYNC.

OR

  • Close Android Studio.

  • And delete all the files under this directory:

      C:\Users\user-name\.gradle\wrapper\dists\
    
  • Now open the Android Studio and the necessary files will be downloaded automatically.

Community
  • 1
  • 1
5377037
  • 9,493
  • 12
  • 43
  • 73
1

I also faced same issue sometime ago, I found simple workaround for it.

File ->Invalidate Caches/ Restart -> Select Invalidate and Restart option.

It will clear all local history and restart automatically. All necessary files will be downloaded automatically.

Jitesh Mohite
  • 15,430
  • 6
  • 71
  • 84
1

I too had same sort of issue. Try this:

Tools--> Android--> Sync Project With Gradle Files

This worked for me.

ANUJ TAYAL
  • 106
  • 5
0

Firstly close the android studio then remove all files from /dist folder

**C:\Users\username.gradle\wrapper\dists**

basically, this folder contains gradle

after that open android studio. clear project and build it.

rahul
  • 37
  • 2