cordova phonegap - 在Android平台上安装时出错

时间:2014-03-26 15:26:05

标签: android cordova ubuntu-12.04

我是Cordova和phonegap的新手,但我的ubuntu 12.04上安装了Android。 我按照这个official guide设法安装了cordova。

尽管我的机器支持android sdk,但是当我运行此命令时:

cordova platform add android

我得到以下异常:

 *cordova platform add android

 Creating android project...
 /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
                throw e;
                      ^
Error: An error occurred while listing Android targets
at /root/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when    (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /root/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/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)
root@sergio-Aspire-5755G:/home/sergio/Development/HelloWorld#  cordova platforms ls
Installed platforms: 
Available platforms: android, blackberry10, firefoxos, ubuntu
root@xxx-Aspire-5755G:/home/sergio/Development/HelloWorld# cordova platform add android
Creating android project...
/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
                throw e;
                      ^
Error: An error occurred while listing Android targets
at /root/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when    (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/root/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /root/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit  code 8
at ChildProcess.whenDone (/usr/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)*

我试过看其他帖子,例如this,但没有人帮助过我。

安装了Android sdk 19版

3 个答案:

答案 0 :(得分:1)

1)运行“android avd”命令,并根据以前下载的SDK版本创建至少一个虚拟设备。

2)sudo apt-get install ant1.8

worked for me.

答案 1 :(得分:1)

您需要检查Android SDK的路径是否正确。
检查您的环境变量PATH,ANDROID_PLATFORM_TOOLS,ANDROID_HOME,ANT_HOME,您可以通过echo %ANDROID_HOME%检查所有路径是否正确配置你会知道哪条路径没有正确配置。

答案 2 :(得分:0)

我这样解决了:

将以下行添加到我的.bashrc:

导出路径= $ PATH:/ opt / adt-bundle-linux-x86_64-20131030 / sdk / platform-tools:/ opt / adt-bun dle-linux-x86_64-20131030 / sdk / tools < /强>