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
}
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With