当前位置:   article > 正文

Error:Failed to open zip file.Gradle's dependency cache may be corrupt_error: failed to open zip file. gradle's dependenc

error: failed to open zip file. gradle's dependency cache may be corrupt (th

转载请注明出处:https://blog.csdn.net/YuDBL/article/details/78581508

To take advantage of all the latest features (such as Instant Run), improvements and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.0.0 and Gradle to version 4.1.  You can learn more about this version of the plugin from the release notes.

最近手“不听使唤”,AS提示更新就点啦,结果等了好久,因公司的网不敢恭维就断开了,后来重新开启项目工程时,出现如下提示: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)

Re-download dependencies and sync project (requires network)

估计是文件没更新完或损坏的原因

 

亲身实践解决方式:

方式1:

(1) AS项目中找到文件:build.gradle(Project: xx项目名)

把以前项目的classpath复制过来

(2)AS项目中找到文件:gradle-wrapper.properties

把以前项目的 distributionUrl复制过来

 

方式2:

因为我有强迫症,既然更新了,我就想用最新的版本,于是尝试成功了此种方式。

AS的菜单栏,点击Android Studio,Preferences, Grade

 

 

搜索找到Gradle,点击标注的图标【或 复制路径“/Users/luminal/.gradle”,回到桌面 command+shift +G搜索找到】

 

把目录下最近更新的gradle删除

 

AS项目中找到文件:gradle-wrapper.properties,

拷贝链接放浏览器上:services.gradle.org/distributions/gradle-4.1-all.zip 

即可下载,当然你也可以去网络上搜索下载。下载其他版本更改版本号就行啦,

如:services.gradle.org/distributions/gradle-3.3-all.zip

把下载下来的zip包,拷贝到如上图wrapper/dists 目录下

然后重启AS,AS会自己解压刷新等,就OK啦(建议还是选择网络好点的地方)

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/236180
推荐阅读
相关标签
  

闽ICP备14008679号