无法在cordova 3.3中添加android平台

时间:2013-12-23 21:52:38

标签: android cordova add platform

我试图通过以下方式添加android平台:

$ cordova platform add android

我明白了:

    Creating android project...

/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occured during creation of android sub-project. 

/Users/jannisportmann/.cordova/lib/android/cordova/3.3.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/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:85:29
    at _rejected (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
    at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
    at /Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
    at flush (/Users/jannisportmann/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

    at /usr/local/lib/node_modules/cordova/src/platform.js:244:30
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

我在.bash_profile中指定了SDK的路径,还有什么我需要做的吗?

感谢您的回答!

4 个答案:

答案 0 :(得分:6)

我修好了!!首先,你必须向你的PATH添加android工具和平台工具......

因此请打开您的用户个人资料(在终端类型中:)

nano ~/.profile
PATH=$PATH:/YOUR_ADT_FOLDER/sdk/platform-tools:/YOUR_ADT_FOLDER/sdk/tools
export PATH

保存并输入终端:

. ~/.profile

现在尝试添加您的cordova平台,如果不起作用,请尝试安装apache ant。我正在使用初级操作系统,所以我打开了软件中心,搜索了安装它。看看你的终端上是否有'ant',然后添加你的平台。

答案 1 :(得分:0)

对于OSX,您的路径需要包含/ Users / yourusername

他们的例子:/ Development / adt-bundle / sdk / platform-tools
需要是:/ Users / yourusername / Development / adt-bundle / sdk / platform-tools

使用echo $ PATH检查你的路径(使用大写,区分大小写!)

答案 2 :(得分:0)

这是用于安装.bash_profile(mac),bashrc(linux)或windows

的文档Phonegab docs

和我的.bash_profile:

export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools

访问解决方案here

我希望这有助于你

答案 3 :(得分:-1)

尝试,

cordova platform add android