打开/解压缩zip文件时出现Cordova Build Gradle Error

XBr*_*der 13 android gradle cordova

当我运行:cordova build,我得到了这个:

Running command:/Users/tyrant/workspace/ideaProject/hello/platforms/android/cordova/build
ANDROID_HOME=/Users/tyrant/software/android/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running:/Users/tyrant/workspace/ideaProject/hello/platforms/android/gradlew cdvBuildDebug -b   /Users/tyrant/workspace/ideaProject/hello/platforms/android/build.gradle    -Dorg.gradle.daemon=true
Deleting directory /Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1
Unzipping /Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1-all.zip to /Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b
Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
atorg.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: 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:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.zip.ZipFile.<init>(ZipFile.java:159)
at org.gradle.wrapper.Install.unzip(Install.java:160)
at org.gradle.wrapper.Install.access$400(Install.java:29)
at org.gradle.wrapper.Install$1.call(Install.java:70)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
... 3 more

/Users/tyrant/workspace/ideaProject/hello/platforms/android/cordova/node_modules/q/q.js:126
                throw e;
                      ^
Error code 1 for command:     /Users/tyrant/workspace/ideaProject/hello/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/tyrant/workspace/ideaProject/hello/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/tyrant/workspace/ideaProject/hello/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/tyrant/workspace/ideaProject/hello/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

fil*_*vic 33

This is because you have already downloaded a corrupted version of gradle ZIP in your system directory. (maybe due to inet issues?) Just go to your local path below and remove all contents inside it.

/Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/

Run cordova build again. This will fix your issue for sure.

  • 我有完全相同的问题并采取相同的解决方案:) +1的问题和答案. (2认同)

小智 8

我读了很多这个问题,我找到了2个解决方案,第一个是删除里面的所有内容(正如最后一篇文章所说的那样),但它并不适用于所有人,在我的情况下不是.

另一个解决方案是在项目的本地文件夹中放入zip文件并更改路径,这不是真正的解决方案,因为大小是50 MB ...

所以我找到的最简单的方法就是从Gradle网站下载正确的zip - > https://services.gradle.org/distributions,然后手动将它替换到你的计算机中......这对我来说很有效.

  • 是的.这就是我最终做的事情.在微波炉中更换它..对不起电脑. (2认同)