gradle构建项目失败:Unzipping /home/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all.zip to /home/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9

时间:2021-03-20 01:17:34
Unzipping /home/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all.zip to /home/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:)
at java.util.zip.ZipFile.<init>(ZipFile.java:)
at java.util.zip.ZipFile.<init>(ZipFile.java:)
at org.gradle.wrapper.Install.unzip(Install.java:)
at org.gradle.wrapper.Install.access$(Install.java:)
at org.gradle.wrapper.Install$.call(Install.java:)
at org.gradle.wrapper.Install$.call(Install.java:)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:)
at org.gradle.wrapper.Install.createDist(Install.java:)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:)

原因:下载的 gradle-3.3-all.zip 包不完整

解决方法:

1. 删除路径下的所有文件

cd /home/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9
rm gradle-3.3-all.zip gradle-3.3-all.zip.lck

2. 手动下载gradle-3.3-all.zip文件传到路径下或者使用wget下载。

下载完成后,再次执行构建命令,成功!