导入工程时,由于网络中断,造成以下问题:
Error:Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
<a href="syncProject">Re-download dependencies and sync project (requires network)</a>
造成该问题的原因是:项目所使用的Gradle版本跟cache中Gradle版本不匹配。
解决方案有两种。
(1)删除“.gradle”文件夹。
所要删除的.gredle文件夹有两个,分别位于
(a)系统用户目录下
(b)项目根目录下
注:需要关闭android studio,防止目录被占用。
注:是“.gradle”!!!不是“gradle”
(2)修改项目中的gradle版本号。
版本号位于gradle-wrapper.properties文件中。
本地可用版本号,可以去系统用户的.gradle/wrapper/dists文件夹中查找。
比较推荐方案(2),简单且耗时少。