Android Studio Gradle的依赖项缓存可能已损坏,无法加载

时间:2018-07-30 14:16:36

标签: android android-gradle build.gradle

每当我创建一个新项目或打开一个令人兴奋的项目时, gradle (不创建)就会向我显示此错误

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)

然后将 distributionUrl 从https更改为http并执行 Invalidate Caches / Restart (使缓存无效/重新启动),Gradle开始构建。

1 个答案:

答案 0 :(得分:0)

确保您已连接到网络。

然后打开Android Studio并执行清理和重建任务。

尝试多次使用窗口右上方的刷新按钮同步gradle,然后重试使缓存/重启无效。

确保在存储库中添加了google()和maven()-> build.gradle(项目级别)。

如果其中任何一项成功完成,请尝试删除安装路径中的.android隐藏文件夹。

更新: 尝试进入.gradle隐藏文件夹,然后导航至wrapper文件夹并删除dists文件夹。然后重新启动您的IDE。

您可以参考此问题以获取更多详细信息:Error:Failed to open zip file. Gradle's dependency cache may be corrupt