我在Ubuntu 14.04
安裝Phonegap
通過使用這些命令:安裝科爾多瓦並加入平臺
$ sudo npm install -g phonegap
然後,我通過使用這些命令安裝科爾多瓦:
$ sudo npm install -g cordova
輸出是:
npm WARN engine [email protected]: wanted: {"node":">=0.6","npm":"1"} (current: {"node":"0.10.33","npm":"2.1.5"})
/usr/bin/cordova -> /usr/lib/node_modules/cordova/bin/cordova
[email protected] /usr/lib/node_modules/cordova
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
我使用這個命令創建了一個簡單的項目:
$ cordova create hello com.example.hello HelloWorld
產量爲:
Creating a new cordova project with name "HelloWorld" and id "com.ajay.hello" at location "/home/ajay/hello"
Downloading cordova library for www...
Download complete
然後我用$ cd hello
生成的路徑到項目中。
後來我加入Android平臺:
$ cordova platform add android
這是錯誤:
npm http GET https://registry.npmjs.org/cordova-android/3.6.4
npm http 200 https://registry.npmjs.org/cordova-android/3.6.4
npm http GET https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.4.tgz
npm http 200 https://registry.npmjs.org/cordova-android/-/cordova-android-3.6.4.tgz
Creating android project...
/home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:126
throw e;
^
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
at /home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/lib/check_reqs.js:159:19
at _fulfilled (/home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:760:13)
at /home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:821:14
at flush (/home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
Error: /home/ajay/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
如何設置ANDROID_HOME?任何線索?
有關,如果你使用的是Mac什麼?我犯了同樣的錯誤。 – 2014-12-04 12:35:53