简体   繁体   English

Phonegap平台添加android

[英]Phonegap platform add android

I am having problem with Phonegap. 我在使用Phonegap时遇到问题。 When I want to add platform with following commands got error: 当我想使用以下命令添加平台时出现错误:

$ export PATH=${PATH}:/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/tools 
$ cordova create hello com.example.hello "HelloWorld"
Creating a new cordova project with name "HelloWorld" and id "com.example.hello" at location "/home/matjazmav/hello"
$ cd hello
/hello$ cordova platform add android
Creating android project...

/home/matjazmav/.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 /home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
    at _rejected (/home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
    at /home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
    at /home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
    at flush (/home/matjazmav/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)
Error: /home/matjazmav/.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:126: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)
hello$
  • Ubuntu 12.04 LTS, Ubuntu 12.04 LTS,
  • Phonegap 3.4.0-0.19.18, Phonegap 3.4.0-0.19.18,
  • Cordova 3.4.1-0.1.0, 科尔多瓦3.4.1-0.1.0,
  • Node.js, Node.js的,

    { http_parser: '1.0', node: '0.10.26', v8: '3.14.5.9', ares: '1.9.0-DEV', uv: '0.10.25', zlib: '1.2.3', modules: '11', openssl: '1.0.1e', npm: '1.4.3' } {http_parser:'1.0',节点:'0.10.26',v8:'3.14.5.9',ares:'1.9.0-DEV',uv:'0.10.25',zlib:'1.2.3',模块:'11',openssl:'1.0.1e',npm:'1.4.3'}

  • and PATH is set 并且设置了PATH

    $ echo $PATH /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/tools $ $ echo $ PATH / usr / lib / lightdm / lightdm:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games:/ ProgramFiles / Android / adt-bundle-linux-x86_64-20140321 / sdk / platform-tools:/ ProgramFiles / Android / adt-bundle-linux-x86_64-20140321 / sdk / tools $

在此处输入图片说明

EDIT : Here is my script, I had added ANT, JAVA and ANDROID to PATH: 编辑 :这是我的脚本,我已将ANT,JAVA和ANDROID添加到PATH:

#!/bin/bash
clear
export PATH=${PATH}:/home/matjazmav/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/home/matjazmav/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/tools:/usr/lib/jvm/java-6-openjdk-amd64/bin:/home/matjazmav/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/:/usr/bin/ant/
echo "$PATH"
phonegap create $1 $2 $3
cd ./$1
# phonegap platform add android # [error]
phonegap build android

Here is output ( before updated last two rows ): 这是输出( 在更新最后两行之前 ):

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/matjazmav/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/home/matjazmav/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/tools:/usr/lib/jvm/java-6-openjdk-amd64/bin:/home/matjazmav/ProgramFiles/Android/adt-bundle-linux-x86_64-20140321/sdk/:/usr/bin/ant/
[phonegap] the options /home/matjazmav/hello com.example.hello HelloWorld
[phonegap] created project at /home/matjazmav/hello
   [error] 'platform add android' is not a node /usr/bin/phonegap command. See 'node /usr/bin/phonegap help'

Thanks! 谢谢!

You should also have 你还应该有

  • JAVA_HOME\\bin; JAVA_HOME \\ BIN; (where JAVA_HOME is the location of jdk folder) (其中JAVA_HOME是jdk文件夹的位置)
  • nodejs\\; 的NodeJS \\;
  • ANT_HOME\\bin; ANT_HOME \\ BIN; (where ANT_HOME is the location of Ant folder) (其中ANT_HOME是Ant文件夹的位置)
  • ANDROID_HOME; ANDROID_HOME; (where ANDROID_HOME is the location of android-sdk folder) (其中ANDROID_HOME是android-sdk文件夹的位置)

in your PATH. 在您的路径中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM