Reputation: 3357
I am on mac and trying to build my cordova project for Android. Whenever I run cordova build android
I get following error:
$ cordova build android
ANDROID_HOME=/Users/sharmanitin/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Subproject Path: CordovaLib
ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Result for ECHO $JAVA_HOME:
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Both JAVA and JAVAC command work fine in my terminal. Also, not sure if it matters buy I am using zsh instead of bash on my mac.
Upvotes: 0
Views: 5837
Reputation: 6949
That's because it's not a valid directory. The error itself says its an incorrect directory.
To set the path correctly :-
Check if /usr/libexec/java_home exists.
If it does then try running
export JAVA_HOME=/usr/libexec/java_home
Upvotes: 1