Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova
Solution 1
The error message proved to be true as Apache Ant isn't in the path of Mac OS X Mavericks anymore.
Bulletproof solution:
-
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Install Apache Ant via Homebrew by executing
brew install ant
Run the PhoneGap build again and it should successfully compile and install your Android app.
Solution 2
You can install ANT through macports or homebrew.
But if you want to do without 3rd party package managers, the problem can simply be fixed by downloading the binary release from the apache ANT web site and adding the binary to your system PATH.
For example, on Mountain Lion, in ~/.bash_profile
and ~/.bashrc
my path was setup like this:
export ANT_HOME="/usr/share/ant"
export PATH=$PATH:$ANT_HOME/bin
So after uncompressing apache-ant-1.9.2-bin.tar.bz2
I moved the resulting directory to /usr/share/
and renamed it ant
.
Simple as that, the issue is fixed.
Note Don't forget to sudo chown -R root:wheel /usr/share/ant
Solution 3
As an alternative to homebrew, you could download and install macports. Once you have macports, you can use:
sudo port install apache-ant
Solution 4
it don't needed port and brew! because you have android sdk package.
.1 edit your .bash_profile
export ANT_HOME="[your android_sdk_path/eclipse/plugins/org.apache.ant_1.8.3.v201301120609]"
// its only my org.apache.ant version, check your org.apache.ant version
export PATH=$PATH:$ANT_HOME/bin
.2 make ant command that can executed
chmod 770 [your ANT_HOME/bin/ant]
.3 test if you see below message. that's success!
command line execute: ant
Buildfile: build.xml does not exist!
Build failed
Solution 5
I encountered the same issue when trying to use Cordova. Turns out I already had brew, try which brew
, but it was outdated. So, I had to update it first:
- Update brew:
brew update
- Install Apache Ant:
brew install ant
Mobiletainment
My name is David Pertiller. I'm a passionate software engineer
Updated on July 08, 2022Comments
-
Mobiletainment almost 2 years
Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork.
I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't compatible with a newer one), added the
PATH environment variables
for the SDK'splatform-tools
andtools
and thought I was ready to take off by running the command:phonegap run android
Nevertheless, I got the following error:
[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. ERROR : executing command 'ant', make sure you have ant installed and added to your path.
-
Joakim Wimmerstedt over 10 yearsSame. Your solution was easy and great. Well answered!
-
meaku over 10 yearsAnt is in homebrew-core now. Simply use
brew install ant
-
Husnain Iqbal over 10 yearshow can i install 'ant' for windows and set the path of it
-
Mobiletainment over 10 years@MuhammadHusnain: I suppose you should ask a separate question on Stack Overflow for this one
-
Robert-W over 10 yearsI did something very similar since I don't use homebrew or macports and on mine, I also did not have anything in my path for it. I downloaded the binary release, unzipped it and created a folder called ant in /usr/local then copied from the unzipped binary the bin and lib folder to /usr/local/ant, after that add /usr/local/ant/bin to your path and restart terminal and all was golden, just do what Coyote said and you will have phonegap CLI working in no time.
-
Felix over 10 yearsCOMMAND UPDATE: ruby -e "$(curl -fsSL raw.github.com/mxcl/homebrew/go/install)"
-
John Mark over 10 years@Goaler444: Are you using an old version of macports? Try
port search ant
and look for Apache Ant there. -
Goaler444 over 10 yearsYep, that was it, updated ports by entering 'sudo port -v selfupdate' and it worked. Thanks :)
-
Abhilash Reddy Kallepu over 10 yearsYou just saved me..Hunting for the solution for 8 hours.
-
Chandrashekhar Singh over 10 yearsSee superuser.com/questions/610157/… for updated
brew
instructions. -
Charan Giri over 10 years@JohnMark i still get same error please help. i followed the process you mentioned do i need to install any other
-
John Mark over 10 yearsIs
ant
on your PATH? If you typewhich ant
in the terminal do you get anything? -
Charan Giri over 10 years@JohnMark thank you for response when i typed which ant i got "/usr/local/bin/ant"
-
Wytze over 10 yearsDon't forget to execute "brew doctor" after installing brew and before using brew to install ant.
-
Charan Giri over 10 yearsi tried ruby -e "$(curl -fsSL raw.github.com/Homebrew/homebrew/go/install)" it say unable to access 'github.com/Homebrew/homebrew': Could not resolve proxy:"****" Failed during: git fetch origin master:refs/remotes/origin/master -n how to fix this
-
Charan Giri over 10 yearsi tried ruby -e "$(curl -fsSL raw.github.com/mxcl/homebrew/go/install) it returns ">" and do nothing please help me with the issue
-
Mobiletainment over 10 years@CharanGiri: it seems that you're connecting to the internet via a proxy server. If so, please try to re-execute that command using a direct internet connection instead
-
Charan Giri over 10 years@Mobiletainment Yes that is the issue proxy made installation process go bad.
-
CR47 about 10 years@Mobiletainment I'm getting an error when I do brew install ant: curl: (22) The requested URL returned error: 404 Not Found Error: Download failed: gtlib.gatech.edu/pub/apache/ant/binaries/… It looks like the file doesn't exist? Do I have to update brew maybe?
-
UberNeo about 10 yearsWorks like charm .. i just need to do .. brew update and then brew install ant -- ADT was already been installed on my Mac.
-
Christos Hrousis almost 10 yearsDon't forget
brew update
before you use it, if you already have homebrew installed.... -
bodagetta over 9 yearsThis also fixed the problem on Yosemite
-
Jailbot about 9 yearsAh, this was it. Perfect.
-
Michel about 9 yearsThis should be the accepted answer. Lean and clean. Install what you need. Using Apache Ant only takes 2 minutes of installing.
-
Michel about 9 yearsMy Eclipse is installed in another location. After setting
ANT_HOME="/Applications/eclipse/plugins/orig.apache.ant_1.8.3.v201301120609"
it worked!