我是cordova的新手;android .
我正在尝试通过命令设置一个项目。
$ cordova create hello com.example.hello "HelloWorld"
$ cd hello
$ cordova platform add android
These all ran successfully. But when i go for `$ cordova build android` then it throws errors.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:UsersLodha>cd
C:>cd hello
C:hello>cordova build android
Running command: C:helloplatformsandroidcordovabuild.bat
Buildfile: C:helloplatformsandroidbuild.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 23.0.2
[checkenv] Installed at C:AndroidSdksdk
-setup:
[echo] Project Name: HelloWorld
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
[echo] Resolving Build Target for HelloWorld...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for HelloWorld...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
nodeps:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 23.0.2
[checkenv] Installed at C:AndroidSdksdk
-setup:
[echo] Project Name: CordovaLib
[gettype] Project Type: Android Library
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
[echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: C:helloplatformsandroidCordovaLibant-buildrsObj
[mkdir] Created dir: C:helloplatformsandroidCordovaLibant-buildrsLibs
[echo] ----------
[echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Found new input file
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
BUILD FAILED
C:AndroidSdksdktoolsantbuild.xml:601: The following error occurred while ex
ecuting this line:
C:AndroidSdksdktoolsantbuild.xml:720: The following error occurred while ex
ecuting this line:
C:AndroidSdksdktoolsantbuild.xml:734: Class not found: javac1.8
Total time: 1 second
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:helloplatformsa
ndroidbuild.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: C:helloplatformsandroidcordovabuild.bat: Command failed with exit co
de 2
at ChildProcess.whenDone (C:UsersLodhaAppDataRoamingnpmnode_modulesco
rdovanode_modulescordova-libsrccordovasuperspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
C:hello>
即使我尝试运行ant
或ant clean
,它也会显示
Buildfile: build.xml does not exist!
Build failed
如果试图用ant -diagnotics
来诊断ant
,那么它抛出,
C:hello>ant -diagnostics
------- Ant diagnostics report -------
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
-------------------------------------------
Implementation Version
-------------------------------------------
core tasks : 1.8.4 in file:/C:/Users/Lodha/AppData/Roaming/npm/node_modules/
ant/ant/lib/ant.jar
-------------------------------------------
ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
ant.java.version: 1.8
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: C:UsersLodhaAppDataRoamingnpmnode_modulesantantlibant.ja
r
ant.home: C:UsersLodhaAppDataRoamingnpmnode_modulesantantbin..
-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
ant.home: C:UsersLodhaAppDataRoamingnpmnode_modulesantantbin..
ant-antlr.jar (11550 bytes)
ant-apache-bcel.jar (14548 bytes)
ant-apache-bsf.jar (9733 bytes)
ant-apache-log4j.jar (8861 bytes)
ant-apache-oro.jar (45515 bytes)
ant-apache-regexp.jar (9563 bytes)
ant-apache-resolver.jar (9886 bytes)
ant-apache-xalan2.jar (8097 bytes)
ant-commons-logging.jar (9715 bytes)
ant-commons-net.jar (91451 bytes)
ant-jai.jar (28241 bytes)
ant-javamail.jar (13773 bytes)
ant-jdepend.jar (14024 bytes)
ant-jmf.jar (12541 bytes)
ant-jsch.jar (46176 bytes)
ant-junit.jar (108138 bytes)
ant-junit4.jar (12923 bytes)
ant-launcher.jar (18429 bytes)
ant-netrexx.jar (16215 bytes)
ant-swing.jar (13497 bytes)
ant-testutil.jar (21004 bytes)
ant.jar (1941731 bytes)
-------------------------------------------
USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: C:UsersLodha
No such directory.
-------------------------------------------
Tasks availability
-------------------------------------------
image : Missing dependency javax.media.jai.PlanarImage
sshexec : Missing dependency com.jcraft.jsch.Logger
scp : Missing dependency com.jcraft.jsch.Logger
sshsession : Missing dependency com.jcraft.jsch.Logger
jdepend : Missing dependency jdepend.xmlui.JDepend
A task being missing/unavailable should only matter if you are trying to use it
-------------------------------------------
org.apache.env.Which diagnostics
-------------------------------------------
Not available.
Download it at http://xml.apache.org/commons/
-------------------------------------------
XML Parser information
-------------------------------------------
XML Parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
XML Parser Location: unknown
Namespace-aware parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$J
AXPSAXParser
Namespace-aware parser Location: unknown
-------------------------------------------
XSLT Processor information
-------------------------------------------
XSLT Processor : com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
XSLT Processor Location: unknown
-------------------------------------------
System properties
-------------------------------------------
java.runtime.name : Java(TM) SE Runtime Environment
sun.boot.library.path : C:Program FilesJavajdk1.8.0_11jrebin
java.vm.version : 25.11-b03
ant.library.dir : C:UsersLodhaAppDataRoamingnpmnode_modulesantantlib
java.vm.vendor : Oracle Corporation
java.vendor.url : http://java.oracle.com/
path.separator : ;
java.vm.name : Java HotSpot(TM) Client VM
file.encoding.pkg : sun.io
user.script :
user.country : IN
sun.java.launcher : SUN_STANDARD
sun.os.patch.level : Service Pack 1
java.vm.specification.name : Java Virtual Machine Specification
user.dir : C:hello
java.runtime.version : 1.8.0_11-b12
java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs : C:Program FilesJavajdk1.8.0_11jrelibendorsed
os.arch : x86
java.io.tmpdir : C:UsersLodhaAppDataLocalTemp
line.separator :
java.vm.specification.vendor : Oracle Corporation
user.variant :
os.name : Windows 7
ant.home : C:UsersLodhaAppDataRoamingnpmnode_modulesantantbin..
sun.jnu.encoding : Cp1252
java.library.path : C:Program FilesJavajdk1.8.0_11bin;C:WindowsSunJavabi
n;C:Windowssystem32;C:Windows;C:Program FilesJavajdk1.8.0_11;C:Program Fi
lesJavajdk1.8.0_11bin;C:Program FilesPC Connectivity Solution;C:Windowss
ystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShel
lv1.0;C:Program FilesTortoiseSVNbin;C:Python27;C:Python27Libsite-packag
es;C:Python27Scripts;C:Program FilesGooglegoogle_appengine;C:Program Files
IntelOpenCL SDK2.0binx86;C:Python27Libsite-packages/django;C:Program Fi
lesQuickTimeQTSystem;C:AndroidSdksdkplatform-tools;C:AndroidSdksdktools
;C:AndroidSdksdkbuild-tools;C:Program Filesnodejs;C:UsersLodhaAppDataR
oamingnpm;C:UsersLodhaAppDataRoamingnpmnode_modulesantantbin;C:Progra
m FilesIDM Computer SolutionsUltraEdit;C:Program FilesWinRAR;C:Program Fil
esGooglegoogle_appengine;;.
java.specification.name : Java Platform API Specification
java.class.version : 52.0
sun.management.compiler : HotSpot Client Compiler
os.version : 6.1
user.home : C:UsersLodha
user.timezone : Asia/Calcutta
java.awt.printerjob : sun.awt.windows.WPrinterJob
java.specification.version : 1.8
file.encoding : Cp1252
user.name : Lodha
java.class.path : C:UsersLodhaAppDataRoamingnpmnode_modulesantantbin..
libant-launcher.jar;C:hello.;C:Program FilesJavajre8libextQTJava.zip;
C:UsersLodhaAppDataRoamingnpmnode_modulesantantlibant-antlr.jar;C:Use
rsLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-bcel.jar;C:Use
rsLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-bsf.jar;C:User
sLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-log4j.jar;C:Use
rsLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-oro.jar;C:User
sLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-regexp.jar;C:Us
ersLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-resolver.jar;C
:UsersLodhaAppDataRoamingnpmnode_modulesantantlibant-apache-xalan2.jar
;C:UsersLodhaAppDataRoamingnpmnode_modulesantantlibant-commons-logging
.jar;C:UsersLodhaAppDataRoamingnpmnode_modulesantantlibant-commons-net
.jar;C:UsersLodhaAppDataRoamingnpmnode_modulesantantlibant-jai.jar;C:
UsersLodhaAppDataRoamingnpmnode_modulesantantlibant-javamail.jar;C:Use
rsLodhaAppDataRoamingnpmnode_modulesantantlibant-jdepend.jar;C:UsersL
odhaAppDataRoamingnpmnode_modulesantantlibant-jmf.jar;C:UsersLodhaApp
DataRoamingnpmnode_modulesantantlibant-jsch.jar;C:UsersLodhaAppDataRo
amingnpmnode_modulesantantlibant-junit.jar;C:UsersLodhaAppDataRoaming
npmnode_modulesantantlibant-junit4.jar;C:UsersLodhaAppDataRoamingnpmn
ode_modulesantantlibant-launcher.jar;C:UsersLodhaAppDataRoamingnpmnode
_modulesantantlibant-netrexx.jar;C:UsersLodhaAppDataRoamingnpmnode_mod
ulesantantlibant-swing.jar;C:UsersLodhaAppDataRoamingnpmnode_modulesa
ntantlibant-testutil.jar;C:UsersLodhaAppDataRoamingnpmnode_modulesant
antlibant.jar;C:Program FilesJavajdk1.8.0_11jrelibtools.jar
java.vm.specification.version : 1.8
sun.arch.data.model : 32
java.home : C:Program FilesJavajdk1.8.0_11jre
sun.java.command : org.apache.tools.ant.launch.Launcher -cp .;C:Program FilesJ
avajre8libextQTJava.zip -diagnostics
java.specification.vendor : Oracle Corporation
user.language : en
awt.toolkit : sun.awt.windows.WToolkit
java.vm.info : mixed mode, sharing
java.version : 1.8.0_11
java.ext.dirs : C:Program FilesJavajdk1.8.0_11jrelibext;C:WindowsSunJav
alibext
sun.boot.class.path : C:Program FilesJavajdk1.8.0_11jrelibresources.jar;C:
Program FilesJavajdk1.8.0_11jrelibrt.jar;C:Program FilesJavajdk1.8.0_11
jrelibsunrsasign.jar;C:Program FilesJavajdk1.8.0_11jrelibjsse.jar;C:Pr
ogram FilesJavajdk1.8.0_11jrelibjce.jar;C:Program FilesJavajdk1.8.0_11j
relibcharsets.jar;C:Program FilesJavajdk1.8.0_11jrelibjfr.jar;C:Program
FilesJavajdk1.8.0_11jreclasses
sun.stderr.encoding : cp437
java.vendor : Oracle Corporation
file.separator :
java.vendor.url.bug : http://bugreport.sun.com/bugreport/
sun.cpu.endian : little
sun.io.unicode.encoding : UnicodeLittle
sun.stdout.encoding : cp437
sun.desktop : windows
sun.cpu.isalist : pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
-------------------------------------------
Temp dir
-------------------------------------------
Temp dir is C:UsersLodhaAppDataLocalTemp
Temp dir is writeable
Temp dir alignment with system clock is 184 ms
-------------------------------------------
Locale information
-------------------------------------------
Timezone India Standard Time offset=19800000
-------------------------------------------
Proxy information
-------------------------------------------
Java1.5+ proxy settings:
Direct connection
C:hello>
有谁能告诉我我哪里错了吗?,如果您需要更多的信息,请告诉我。
谢谢
添加环境变量了吗?
- 出口路径= ${}路径:/…/平台工具
- export PATH = ${PATH}:/…/tools
- export PATH = ${PATH}:/…/build-tools
您必须放置sdk的正确路径
在我的情况下,这是因为我安装了最新版本的Android SDK构建工具(21)。当我卸载它(在Android SDK管理器中)并将版本20作为Android SDK Build-tools的最高安装版本时。