Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jquery - Phonegap platform add android

I am having problem with 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,
  • Phonegap 3.4.0-0.19.18,
  • Cordova 3.4.1-0.1.0,
  • 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' }

  • and PATH is set

    $ 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 $

enter image description here

EDIT: Here is my script, I had added ANT, JAVA and ANDROID to 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should also have

  • JAVA_HOMEin; (where JAVA_HOME is the location of jdk folder)
  • nodejs;
  • ANT_HOMEin; (where ANT_HOME is the location of Ant folder)
  • ANDROID_HOME; (where ANDROID_HOME is the location of android-sdk folder)

in your PATH.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...