我正在使用 macbook 并使用 cordova 进行开发。现在,我想创建一个 Android apk,但是,当我键入 cordova platform add android
时,我得到了这个:
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
好的,这条消息应该很清楚下一步要做什么,但是不知道该做什么。当我搜索时,我一直在了解如何在 Windows 中解决此问题,但无法按照步骤操作。
我应该做什么(以及如何做)?
谢谢
编辑:
我在尝试编译 apk 时已经安装了 Android SDK。
更多信息:
因为我无法安装 ANT,所以我卸载了它:brew uninstall ant
。但是当 brew install ant
再次出现时,我得到了:
$ brew install ant
==> Downloading http://www.apache.org/dyn/closer.cgi?path=ant/binaries/apache-ant-1.9.3-bin.tar.gz
==> Best Mirror http://apache.rediris.es/ant/binaries/apache-ant-1.9.3-bin.tar.gz
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "ant"
Download failed: http://apache.rediris.es/ant/binaries/apache-ant-1.9.3-bin.tar.gz
最佳答案
在开始使用 Android 之前要确保您已完成的一些事情:
确保安装了 ANT:
尝试ant --version
,如果command not found
你需要安装ANT。
我发现的最简单的方法是使用Homebrew
。如果您没有安装自制软件,get it here
安装后运行
homebrew update
homebrew install ant
解压 Android SDK:
下载并解压SDK包,将其放置在容易找到的位置。
然后将 tools
和 platform-tools
路径添加到全局 PATH
中,如下所示:
vi ~/.bash_profile
添加这一行:
export PATH=/path/to/android/sdk/tools:/path/to/adnroid/sdk/platform-tools:$PATH
退出终端并重新打开终端。
现在您应该能够在您的项目文件夹中运行cordova platform add android
。
关于android - 在 mac 中添加 android 时出现 Cordova 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23998542/