简体   繁体   中英

Cannot build project using cordova

I have added ANDROID_HOME , JAVA_HOME as you can see below. But cannot build.

npm version 2.10.1 node version 0.12.4 java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b15) Java HotSpot(TM) Client VM (build 25.45-b02, mixed mode, sharing)

OS Windows 7

Cordova version 5.0.0

The project is the default cordova project created by running cordova create hello com.vipul.hello HelloWorld

This is the error I get.

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>

The solution as pointed out by Ivan Gabriele in the comment was the gradle zip lying in C:\\Documents and Settings\\Vipul\\.gradle\\wrapper\\dists\\gradle-2.2.1-all\\2m8005s69iu8v0oiejfej094b that was the issue, probably caused because of an update and incorrect download, when I switched from 1.6 to 2.2.1.

I just replaced the file gradle-2.2.1-all.zip with a fresh copy and all is well now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM