使用cordova启动时出错:命令执行失败:ant jar

时间:2013-11-20 18:28:16

标签: android ant cordova

您好我试图使用phonegap创建我的第一个应用程序,但是当我运行“ phonegap run android ”时,它会向我抛出错误:

[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
   [error] An error occured during creation of android sub-project. Creating Cordova project for the Android platform:
Command failed to execute : ant jar

当我使用 cordova -d platform添加android

Creating android project...
Running bin/create for platform "android" with command: ""C:\Users\Fernando\.cordova\lib\android\cordova\3.1.0\bin\create"  "C:\Users\Fernando\Desktop\phonegap_examples\hello_phonegap\platforms\androi
d" "com.phonegap.helloworld" "HelloWorld"" (output to follow)
Creating Cordova project for the Android platform:

Error: An error occured during creation of android sub-project. Creating Cordova project for the Android platform:

Command failed to execute : ant jar

    at C:\Users\Fernando\AppData\Roaming\npm\node_modules\cordova\src\platform.js:246:30
    at ChildProcess.exithandler (child_process.js:636:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:730:16)
    at Process.ChildProcess._handle.onexit (child_process.js:797:5)

在我的路上,我补充道:

C:\apache-ant-1.9.2\bin;
C:\Program Files\adt_Android\sdk\platform-tools;
C:\Program Files\adt_Android\sdk\tools

我不知道我错过了什么,我搜索了它,但我找不到任何东西。

2 个答案:

答案 0 :(得分:0)

发布于phonegap run android: command failed to execute: ant jar - on Windows

  

ANT工具在JRE lib目录中找不到tools.jar。

     

为了解决您的问题:

     

将tools /jar从Java / JDK1.7.0_45 / lib目录复制到Java / JRE7 / lib   目录并运行命令cordova platform再次添加android。

     

希望这会对你有所帮助。

答案 1 :(得分:0)

您还可以将jdk1.8 / libs / tools.jar添加到ant / lib文件夹。