XBroder XBroder - 14 days ago 7
Android Question

Cordova Build Gradle Error while opening/extracting zip file

When I Run: cordova build, I got this:

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)


How should I solve this problem?

Answer

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.