2

I installed Phonegap in Ubuntu 14.04 by using these commands:

$ sudo npm install -g phonegap  

Then I installed cordova by using these commands:

$ sudo npm install -g cordova

Output was:

npm WARN engine npm@1.3.4: 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
cordova@4.0.0 /usr/lib/node_modules/cordova
├── q@0.9.7
├── underscore@1.4.4
├── nopt@2.2.1 (abbrev@1.0.5)
└── cordova-lib@4.0.0 (osenv@0.0.3, properties-parser@0.2.3, bplist-parser@0.0.5, mime@1.2.11, semver@2.0.11, unorm@1.3.3, shelljs@0.3.0, dep-graph@1.1.0, elementtree@0.1.5, xcode@0.6.7, glob@3.2.11, npmconf@0.1.16, rc@0.3.0, plist@1.0.1, tar@0.1.20, npm@1.3.4, request@2.22.0, d8@0.4.4, cordova-js@3.7.Tne1)

I created a simple project by using this command:

$ cordova create hello com.example.hello HelloWorld

Output was:

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

Then I created path into the project by using $ cd hello.
Then I added android platform:

$ cordova platform add android

And this is the error:

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)

How can I set ANDROID_HOME? Any leads?

Ajay Kulkarni
  • 2,900
  • 13
  • 48
  • 97

3 Answers3

2

You can setup the ANDROID_HOME in you .bashrc by adding these:

ANDROID_HOME=/home/user/android-sdk-linux
export ANDROID_HOME=$ANDROID_HOME
export JAVA_HOME=/usr/lib/jvm/java-7-oracle/

PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/build-tools

Probably you would have to change some values to match your configuration.

You will need to source your .bashrc file or close your terminal window and reopen it.

see also : Ant failed to build on Ubuntu

Community
  • 1
  • 1
dawez
  • 2,714
  • 2
  • 29
  • 50
0

You need to set the path of your Android SDK, Android SDK Tools & Android SDK Platform-tools.

This will solve your problem.

Community
  • 1
  • 1
Dhrumil Shah - dhuma1981
  • 15,166
  • 6
  • 31
  • 39
-1

I just run sudo uninstall cordova then sudo install cordova then cordova platform add android , I am on Mac OSX Yosemite 10.10.3

I hope this helps :)

Jon
  • 1,328
  • 1
  • 11
  • 11