Fixing: Error executing command 'ant' on Mac OS X 10.9 Mavericks
Today I stumbled over an unexpected problem when trying
PhoneGap/Cordova with Mac OS X 10.9 Mavericks. Building a project for iOS went just fine, but building for Android wasn't without some guesswork.
After installing 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) and adding the
PATH environment variables for the SDK's
tools, I 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.
After checking my system for ant, the error message proved to be true since
Apache Ant isn't packaged with Mac OS X Mavericks anymore.
So without further ado, here comes the bulletproof solution on how to fix this easily:
- 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
That's it! Re-run the build and it should successfully compile and run the app.
PS: You can now find this post as Q&A on StackOverflow as well!