bash Android 构建失败“无法运行 ant 版本”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29172325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android build fail 'failed to run ant version'
提问by FHair
I am trying to use ionic cordova to run the sample demo but there is an error when I try to build:
我正在尝试使用 ionic cordova 来运行示例演示,但是当我尝试构建时出现错误:
Famtop myApp $ ionic build android
Running command: "c:\Program Files\nodejs\node.exe" c:\Users\Famtop\myApp\hooks\
after_prepare0_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_prepare0_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)
I have looked at similar questions that suggest I check the path but I am unsure how to do this: I have the latest JDK and Android suite.
我看过类似的问题,建议我检查路径,但我不确定如何执行此操作:我有最新的 JDK 和 Android 套件。
Any help greatly appreciated.
非常感谢任何帮助。
F
F
回答by AtanuCSE
you need to download ANT from this link
then extract it, keep it in some folder. Then add variable in your system variable with name ANT_HOME
然后提取它,将其保存在某个文件夹中。然后使用名称在系统变量中添加变量ANT_HOME
For example
例如
Variable= `ANT_HOME` value= `H:\apache-ant-1.9.3`
Then add this to path variable
然后将此添加到路径变量
%ANT_HOME%\bin;
回答by Shahroon
For Ubuntu users it is simple enough, do
对于 Ubuntu 用户来说,这很简单,做
sudo apt-get install ant
sudo apt-get 安装蚂蚁
and you are done.
你就完成了。
回答by eDriven_Levar
In Window 8 .. once you set these PATHs you may need to reboot before phonegap/cordova/ionic can see the variables. OR If you set them in the command prompt you can use them right away. I found this out the hard way that it doesn't work like it did in Windows 7. Just setting it in control panel is not enough.
在 Window 8 .. 设置这些路径后,您可能需要重新启动,然后 phonegap/cordova/ionic 才能看到变量。或者如果您在命令提示符中设置它们,您可以立即使用它们。我发现这很难,因为它不像在 Windows 7 中那样工作。仅仅在控制面板中设置它是不够的。