vasan
vasan

Reputation: 2223

getting error, while adding android platform for phonegap

Today I started phonegap, as per documentation I am trying to setup my environment into my local machine.

In this process, I installed android SDK and set the environment variables in bashrc file.

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME

ANDROID_HOME=$HOME/Git/adt-bundle-linux/sdk
export ANDROID_HOME
PATH=$PATH:$ANDROID_HOME

ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
export ANDROID_PLATFORM_TOOLS
PATH=$PATH:$ANDROID_PLATFORM_TOOLS

ANDROID_TOOLS=$ANDROID_HOME/tools
export ANDROID_TOOLS
PATH=$PATH:$ANDROID_TOOLS
export PATH

ANT_HOME=/usr/share/ant
export ANT_HOME
PATH=$PATH:$ANT_HOME/bin

I switch to my working director and getting the following error after ran the cordova platform add android

Creating android project...

/home/.cordova/lib/npm_cache/cordova-     
android/3.6.3/package/bin/node_modules/q/q.js:126
                throw e;
                      ^
Error: Failed to run "javac -version", make sure you have a Java JDK (not just a JRE) installed.
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:43:27
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Error: /home/.cordova/lib/npm_cache/cordova-android/3.6.3/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.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
@barrett:~/Git/phonegap/hellowPhonegap$

same command ran with "sudo" like sudo cordova platform add android, throwing the following error.

 /home/.cordova/lib/npm_cache/cordova-android/3.6.3/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/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:158:19
at _fulfilled (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:760:13)
at /home/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/node_modules/q/q.js:821:14
at flush (/home/.cordova/lib/npm_cache/cordova-android/3.6.3/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/.cordova/lib/npm_cache/cordova-android/3.6.3/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.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)

Which command shall I use later. If one of it,what's the problem.

can anyone help me.

Upvotes: 4

Views: 7766

Answers (4)

Jose Mendez
Jose Mendez

Reputation: 43

What happened to me was, that I had the openjre installed, but javac is actually part of the openjdk. Hope this helps someone.

Upvotes: 0

vamsikrishnamannem
vamsikrishnamannem

Reputation: 4847

Add the path to ANDROID_HOME like this

export ANDROID_HOME='your path'

after check the path like echo $ANDROID_HOME

Upvotes: 0

vamsikrishnamannem
vamsikrishnamannem

Reputation: 4847

I face the same problem let's do this javac -version then it show the available versions like

The program 'javac' can be found in the following packages:
 * default-jdk
 * ecj
 * gcj-4.8-jdk
 * openjdk-7-jdk
 * gcj-4.6-jdk
 * openjdk-6-jdk
Try: sudo apt-get install <selected package>

fallow that. I hope this is helps you.

Upvotes: 2

Parsaria
Parsaria

Reputation: 1099

i had same problem add this to your path. in windows i did like this path=%path%;%android_home%/platform-tools

Upvotes: 0

Related Questions