在mac上的cordova android安装错误

时间:2014-03-07 20:39:44

标签: android cordova

我正在尝试创建一个phonegap应用,但每次尝试添加平台时都会收到此错误:

Creating a new cordova project with name "HelloWorld" and id "com.mc2now.hello" at location "/Users/tony/Desktop/eclipse/eclipse"
imac-6:eclipse tony$ cd eclipse
imac-6:eclipse tony$ cordova platform add android
Creating android project...

/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
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.
    at /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:85:29
    at _rejected (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
    at /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
    at /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
    at flush (/Users/tony/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)
Error: /Users/tony/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:112:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)

所以,我的问题是如何将android添加到我的路径?我试过这个:

imac-6:eclipse tony$ export PATH=${PATH}:adt-bundle/sdk/platform-tools:/adt-bundle/sdk/tools

有人可以解释一下我做错了什么吗?非常感谢任何帮助!

3 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,似乎是已安装的adt-bundle中的权限问题。

以下为我修好了:

$ sudo chown -R $(whoami) /Development/adt-bundle

答案 1 :(得分:1)

尝试转到您的用户目录cd ~/并修改.bash_profile,然后将export PATH=${PATH}:adt-bundle/sdk/platform-tools:/adt-bundle/sdk/tools添加到该文件中。

保存,关闭终端并重新启动。

答案 2 :(得分:0)

我的linux机箱上出现了同样的错误。 我修复了android sdk" tools"我的系统PATH env变量中的subdir。 例如:

export PATH="/opt/android/adt-bundle-linux-x86_64-20140321/sdk/tools:$PATH"

你还应该包括" platform-tools"子目录。