Gradle Error: cannot open zip file

When I open a project, it will throw an error:

Error: Could not open the zip file. Gradle dependency cache may be (this sometimes happens after a network connection timeout). Restart dependencies and synchronization project (network required)

I tried this: Error : Could not open the zip file. The gradle dependency cache may be corrupted (this sometimes happens 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
}
+6
source share
3 answers

:

  • Android Studio.

  • :

    C:\Users\user-name\.gradle\wrapper\dists\
    
  • Android Studio, .

+2

-, .

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

. .

+1

I had the same problem too. Try the following:

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

It worked for me.

+1
source

Source: https://habr.com/ru/post/1015750/


All Articles