小编典典

PhoneGap / Cordova Android开发

node.js

更新1:

这就是我最后所做的一切:

sudo aptitude install -y python-software-properties python g++ make
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo aptitude update
sudo aptitude install nodejs
sudo aptitude install npm
sudo npm install -g cordova
sudo npm install -g phonegap
phonegap create my-app
cd my-app
export PATH=${PATH}:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/tools
sudo aptitude install ant
cordova platform add android
android create avd --name my_and --target 1
phonegap run android

那不是必需的吗?


原始问题:

在我的Ubuntu 12.04计算机上,我刚刚使用npm和cordova安装了node.js:

$ node -v
v0.10.23

$ npm -v
1.3.17

$ cordova -v
3.3.0-0.1.1

当我尝试添加android时:

$ cordova platform add android

我得到以下输出:

Creating android project...

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

/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
                    throw e;
                          ^
Error: An error occurred while listing Android targets
    at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
    at _rejected (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
    at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
    at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
    at flush (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

    at /usr/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)

有人知道为什么会发生这种情况以及如何解决吗?

我在PhoneGap上遇到了同样的问题。


阅读 212

收藏
2020-07-07

共1个答案

小编典典

Android工具二进制文件可能不在您的路径中。

根据PhoneGap文档(http://docs.phonegap.com/en/2.9.0/guide_getting-
started_android_index.md.html),您需要在PATH环境变量中包括Android SDK的 工具平台工具

导出PATH = $ {PATH}:/ Development / adt-bundle / sdk / platform-tools:/
Development / adt-bundle / sdk / tools

开发是您安装SDK的路径。

2020-07-07