FHair FHair - 5 months ago 37
Android Question

Android build fail 'failed to run ant version'

I am trying to use ionic cordova to run the sample demo but there is an error when I try to build:

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)


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.

Any help greatly appreciated.

F

Answer

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

For example

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

Then add this to path variable

%ANT_HOME%\bin;
Comments