android - Cordova 和使用命令行设置 Android

标签 android cordova sdk command

我正在尝试将我现有的项目从 cordova 2.1 迁移到最新的 3.1,它可以通过命令行安装,

我已经安装了 Android SDK,

所以:

sudo npm install -g cordova // All good
cordova create hello com.example.hello HelloWorld // All good
cordova platform add android // Then it fires:

Checking Android requirements...
[Error: The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ]

所以我安装了 Macports 并尝试:

sudo port install android

哪些日志:

Warning: All compilers are either blacklisted or unavailable; defaulting to first fallback option
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
--->  Cleaning android
--->  Scanning binaries for linking errors: 100.0%
--->  No broken files found.

知道我在这里错过了什么吗?

最佳答案

在 MAC 上运行 cordova Android 1000000000%。我争取解决方案,现在我正在努力尝试这个@Toni Michel Caubet。我很乐意分享我的答案。

步骤:

打开您的终端,然后,

  1. 触摸 ~/.bash_profile

  2. 打开 ~/.bash_profile

  3. PATH="/Users/System-Name/Documents/android-sdk-macosx/sdk/tools:/Development/android-sdk-macosx/sdk/platform-tools:$PATH"(这是存储在我的系统中的 Android SDK 位置)

enter image description here

4.保存文件并退出文本编辑器。

5.执行你的.bash_profile来更新你的路径:

来源 ~/.bash_profile

如果你想查看你的环境路径:

7.在你的终端输入:set

看完之后可以点赞

enter image description here

8.就你说得非常正确而言。在你输入命令后,比如 cordova platform add android。你得到以下错误。因为 Java SDK 没有设置环境 PATH。

enter image description here

9.打开 ~/.bash_profile. 添加 JAVA_HOME 值

enter image description here

10.你可以看到你的环境像STEP 7 set。您应该能够看到:

enter image description here

11.成功创建环境,现在可以使用Cordova或PhoneGap创建Android项目

enter image description here

关于android - Cordova 和使用命令行设置 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20080325/

相关文章:

android - 共享 Intent - 获取结果、共享位置和状态?

android - 将 proguard 与 Hyperledger Iroha 结合使用时,我的应用程序崩溃

android - 尝试在 actionBarActivity 中启动 fragment

android - cordova中的 Assets 文件夹结构

java - 如何使用 Android SDK 在 onCreate 语句中动态更改 Activity 的背景颜色?

android - 使用 Eclipse 4.2 和 SDK 20 创建新项目

java - Android表格行横线

ios - 我的 sqlite 数据存储在 iOS 模拟器中的什么位置?

javascript - PhoneGap 上的 Ajax 请求在 2G 上比 3G 上更快

iphone - iOS SDK写在UIImage上绘制文本