Failed to open zip file. Gradle's dependency cache may be corrupt 错误解决

新建一个项目的时候,出现以下的错误:

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:打开一个可以运行的项目,查看gradle-wrapper.properties 文件中 distributionUrl 的版本号,这里是4.6-all.zip,根据正确的版本号进行修改。

2:接着打开 build.gradle

查看classpath的版本号 ,并进行修改。

3:重新编译,成功。