我添加了ANDROID_HOME
,JAVA_HOME
,如下所示。
但无法建立。
npm版本2.10.1 节点版本0.12.4 java版" 1.8.0_45" Java(TM)SE运行时环境(构建 1.8.0_45-b15)Java HotSpot(TM)客户端VM(版本25.45-b02,混合模式,共享)
OS Windows 7
Cordova版本5.0.0
该项目是通过运行创建的默认cordova项目
cordova create hello com.vipul.hello HelloWorld
这是我得到的错误。
C:\xampp\htdocs\hello>cordova build
Running command: C:\xampp\htdocs\hello\platforms\android\cordova\build.bat
ANDROID_HOME=C:\Users\Vipul\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0
Running: C:\xampp\htdocs\hello\platforms\android\gradlew cdvBuildDebug -b C:\xam
pp\htdocs\hello\platforms\android\build.gradle -Dorg.gradle.daemon=true
org.gradle.api.UncheckedIOException: java.util.zip.ZipException: zip file is emp
ty
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModulePro
perties(DefaultModuleRegistry.java:209)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(De
faultModuleRegistry.java:119)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(Def
aultModuleRegistry.java:108)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.module(Defaul
tModuleRegistry.java:149)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(De
faultModuleRegistry.java:120)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(Def
aultModuleRegistry.java:108)
at org.gradle.api.internal.DefaultClassPathProvider.findClassPath(Defaul
tClassPathProvider.java:33)
at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(Default
ClassPathRegistry.java:34)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:47)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.ja
va:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:220)
at java.util.zip.ZipFile.<init>(ZipFile.java:150)
at java.util.zip.ZipFile.<init>(ZipFile.java:164)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModulePro
perties(DefaultModuleRegistry.java:201)
... 17 more
C:\xampp\htdocs\hello\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\xampp\htdocs\hello\platforms\
android\gradlew cdvBuildDebug -b C:\xampp\htdocs\hello\platforms\android\build.g
radle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: C:\xampp\htdocs\hello\platforms\andr
oid\cordova\build.bat: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: C:\xampp\htdocs\hello\platforms\android\cordova\build.bat: Command failed
with exit code 8
at ChildProcess.whenDone (C:\Users\Vipul\AppData\Roaming\npm\node_modules\co
rdova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)
C:\xampp\htdocs\hello>
答案 0 :(得分:1)
Ivan Gabriele在评论中指出的解决方案是C:\Documents and Settings\Vipul\.gradle\wrapper\dists\gradle-2.2.1-all\2m8005s69iu8v0oiejfej094b
中的gradle zip是问题,可能是由于更新和错误下载造成的,当我从1.6切换到2.2.1时。
我刚刚用新副本替换了文件gradle-2.2.1-all.zip
,现在一切都很顺利。