当我跑步: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)
我该如何解决这个问题?
答案 0 :(得分:33)
这是因为您已经在系统目录中下载了损坏版本的gradle ZIP。 (可能是由于inet问题?)只需转到下面的本地路径并删除其中的所有内容。
/Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/
再次运行cordova build
。这肯定会解决您的问题。
答案 1 :(得分:7)
我读了很多这个问题,我找到了2个解决方案,第一个是删除里面的所有内容(正如最后一篇文章所说的那样),但它并不适用于所有人,在我的情况下,不是吨。
另一个解决方案是将zip文件放在项目的本地文件夹中并更改路径,这不是真正的解决方案,因此大小为50 MB ...
所以我发现最简单的方法就是从Gradle网站下载正确的zip - &gt; https://services.gradle.org/distributions只需在您的计算机上手动替换它......这对我来说很有效。
答案 2 :(得分:1)
检查您是否有下载限制,如果是,请手动下载gradle zip文件,将其放在/Users/tyrant/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/等文件夹中然后运行命令。
答案 3 :(得分:1)
对于在首次构建本机反应动作Android应用时遇到此问题的任何人,它可能是gradle-2.4文件,通常位于:
/var/root/.gradle/wrapper/dists/gradle-2.4-all/<some_string>/gradle-2.4
只需手动删除zip文件,下载新副本并替换。