Android构建失败'无法运行ant版本'

时间:2015-03-20 17:19:13

标签: android bash cordova ionic

我正在尝试使用离子cordova来运行示例演示,但是当我尝试构建时出现错误:

    Famtop myApp $ ionic build android
Running command: "c:\Program Files\nodejs\node.exe" c:\Users\Famtop\myApp\hooks\
after_prepare\010_add_platform_class.js c:/Users/Famtop/myApp
add to body class: platform-android
Running command: "c:\Program Files\nodejs\node.exe" c:\Users\Famtop\myApp\hooks\
after_prepare\020_remove_sass_from_platforms.js c:/Users/Famtop/myApp
Running command: c:\Users\Famtop\myApp\platforms\android\cordova\build.bat
c:\Users\Famtop\myApp\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error: Failed to run "ant -version", make sure you have ant installed and added
to your PATH.
    at c:\Users\Famtop\myApp\platforms\android\cordova\lib\check_reqs.js:43:27
    at ChildProcess.exithandler (child_process.js:751:5)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
ERROR building one of the platforms: Error: c:\Users\Famtop\myApp\platforms\andr
oid\cordova\build.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: c:\Users\Famtop\myApp\platforms\android\cordova\build.bat: Command failed
 with exit code 1
    at ChildProcess.whenDone (c:\Users\Famtop\AppData\Roaming\npm\node_modules\c
ordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

我看过类似的问题,建议我查看路径,但我不确定如何做到这一点:我有最新的JDK和Android套件。

非常感谢任何帮助。

˚F

3 个答案:

答案 0 :(得分:9)

您需要下载ANT from this link

然后提取它,将其保存在某个文件夹中。然后在名为ANT_HOME

的系统变量中添加变量

例如

Variable= `ANT_HOME` value= `H:\apache-ant-1.9.3`

然后将其添加到路径变量

%ANT_HOME%\bin;

答案 1 :(得分:2)

对于Ubuntu用户来说,这很简单,做

sudo apt-get install ant

你已经完成了。

答案 2 :(得分:0)

在Window 8中..一旦设置了这些PATH,您可能需要重启才能在phonegap / cordova / ionic中看到变量。或者如果在命令提示符下设置它们,则可以立即使用它们。我发现这很难,它不像在Windows 7中那样工作。仅仅在控制面板中设置它是不够的。