无法使用cordova构建项目

无法使用cordova构建项目

本文介绍了无法使用cordova构建项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已添加 ANDROID_HOME JAVA_HOME ,如下所示。
但是无法构建。

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

OS Windows 7

OS Windows 7

Cordova版本5.0.0

Cordova version 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>


推荐答案

Ivan Gabriele在评论中指出的解决方案是gradle zip in C:\ Document and Settings \Vipul \ .gradle \wrapper \dists\gradle-2.2.1-all \2m8005s69iu8v0oiejfej094b 这是问题,可能是由于更新和错误下载造成的,当我从1.6切换到2.2.1。

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.

我刚刚更换了文件 gradle-2.2.1-all.zip 带有新副本,一切都很好。

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

这篇关于无法使用cordova构建项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:14