Reputation: 41
Im getting this on one of my macs when I try to compile even "hello world"
Error:Execution failed for task ':app:compileDebugJava'.
Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
On my other mac, I dont have any problems. The setup is the same as far as I can tell. It's just that for some reason, on one machine, Android Studio / Gradle pops this error message.
I have set
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
running /usr/libexec/java_home gives:
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
running javac -version gives :
javac 1.7.0_60-ea
running java -version gives:
java version "1.7.0_60-ea"
Java(TM) SE Runtime Environment (build 1.7.0_60-ea-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
In Android Studio I have set file->other settings->default project settings-> JDK location to the JDK location listed above.
I've run out of options, why am I still getting this message?
thanks for any help, Ive wasted hours on this already.
Upvotes: 4
Views: 2008
Reputation: 6871
One possible solution is :
The android studio needs the jdk 1.6+
by default, but your JDK
is 1.7.
You can show the package content
of the Android Studio
in Applications
folder, and the open the info.plist
, change the JVM version
to your JDK's version, which is 1.7* here.
(you see, my JDK version is 1.8 in my computer)
Upvotes: 0
Reputation: 149
Rich_LogicBox solution also worked for me. I've struggled for weeks with different java versions making no difference. When I removed the jar files placed in /Library/Java/Extensions by auskey, the Android Studio error disappeared.
Upvotes: 1
Reputation: 46
My findings from an identical error proved to be due to a clash of Java Jar files that were not related with the Android studio install. Specifically the tools.jar and auskey.jar under /Library/Java/Extensions More info here
Upvotes: 2