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

转载请注明出处: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啦(建议还是选择网络好点的地方)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

被开发耽误的大厨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值