Error:Failed to open zip file. Gradle's dependency cache may be corrupt

异常信息

构建项目时异常报错:

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

分析

字面意思:
打开zip文件失败,Gradle依赖缓存可能损坏(可能是网络连接超时导致),"syncProject"重新下载依赖和同步项目(需要网络)

通过AndroidStudio下载gradle依赖时可能因为网络原因未下载完整的zip文件,导致不能正常解压使用。

解决方案

  1. gradle-wrapper.properties配置中的distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip ZIP下载后放在gradle home目录中。

  2. gradle home目录在Settings - Build, Exectuion,Deployment - Gradle下可见,为空可手动设置。

  3. 再次同步后问题解决。


参考:

Error:Failed to open zip file. Gradle's dependency cache may be corrupt

Error:Failed to open zip file. Gradle's dependency cache may be corrupt

你可能感兴趣的:(Error:Failed to open zip file. Gradle's dependency cache may be corrupt)