问题
I've updated my Mac to Yosimite. I've also installed JDK 1.8x. However, when I go phonegap run android
I get the following:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/Users/profile/.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 /Users/profile/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/lib/check_reqs.js:43:27
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
{ [Error: /Users/profile/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8] code: 8 }
[error] /Users/profile/.cordova/lib/npm_cache/cordova-android/3.6.3/package/bin/create: Command failed with exit code 8
I have setup my $JAVA_HOME
, and when I do javac -version
I get javac 1.8.0_25
. Everything seems to be fine.
The only thing which I can think of is phonegap is changing the path at run time
回答1:
Okay,
So for some reason Java 1.7 and 1.8 don't want to play nice no matter how much encouragement I gave it. What I had to do is download Java 1.6 and use that. The thing with this though you can't get this from the Java Download site. Instead, you have to get it from Apple. You can get this here
http://support.apple.com/kb/DL1572
This is the same version of Java which was included in OSX 2013-005. Once you have downloaded this you will now have multiple versions of Java. The Java 1.6 version from Apple doesn't get placed in the same spot as the ones from Oracle. The Apple one get's placed in the System Library. This means you have to change the JAVA_HOME
var to this system one. Once I did that it was done.
So this is how I set my path:
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
I have no idea why I couldn't get Java 1.7 and 1.8 working, but this is the only thing which fixed it for me.
来源:https://stackoverflow.com/questions/26801562/phonegap-cordova-javac-version-not-found