android – Gradle错误:无法打开zip文件

前端之家收集整理的这篇文章主要介绍了android – Gradle错误:无法打开zip文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我打开Project时会出错:

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)

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

但不适合我.

这是我的build.gradle文件

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 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
}
最佳答案
前段时间我也面临同样的问题,我找到了简单的解决方法.

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

它将清除所有本地历史记录并自动重启.将自动下载所有必需的文件.

猜你在找的Android相关文章