使用 PhoneGap/Cordova 为 Android 构建时,在 Mac OS X 10.9 Mavericks 上执行命令“ant"时出错 [英] Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova
问题描述
今天我在 Mac OS X Mavericks 上试用了 PhoneGap/Cordova.针对 iOS 的构建过程很顺利,但针对 Android 的构建并非没有一些猜测.
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.
我通过 Android SDK 管理器安装了 Android 4.2.2(我不得不使用旧的 API v17,因为它与较新的不兼容),添加了 SDK 的
,并认为我已准备好通过运行以下命令:platform-tools
和 tools
的 PATH 环境变量
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's platform-tools
and tools
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.
推荐答案
该错误消息被证明是正确的,因为 Apache Ant 不再位于 Mac OS X Mavericks 的路径中.
The error message proved to be true as Apache Ant isn't in the path of Mac OS X Mavericks anymore.
防弹解决方案:
通过在终端中执行以下命令下载并安装 Homebrew:
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/主/安装)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
通过执行
Install Apache Ant via Homebrew by executing
brew 安装蚂蚁
再次运行 PhoneGap 构建,它应该会成功编译并安装您的 Android 应用.
Run the PhoneGap build again and it should successfully compile and install your Android app.
这篇关于使用 PhoneGap/Cordova 为 Android 构建时,在 Mac OS X 10.9 Mavericks 上执行命令“ant"时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!