简体   繁体   English

Mac上的Android Studio:无法找到系统编译器

[英]Android Studio on mac : cant find System compiler

Im getting this on one of my macs when I try to compile even "hello world" 当我尝试编译“你好世界”时,我在我的一个Mac上得到这个

Error:Execution failed for task ':app:compileDebugJava'. 错误:任务':app:compileDebugJava'的执行失败。

Cannot find System Java Compiler. 找不到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. 确保已安装JDK(而不仅仅是JRE)并将JAVA_HOME系统变量配置为指向相应目录。

On my other mac, I dont have any problems. 在我的另一台Mac上,我没有任何问题。 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. 只是出于某种原因,在一台机器上,Android Studio / Gradle弹出此错误消息。

I have set 我已经设定

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home JAVA_HOME = /图书馆/的Java / JavaVirtualMachines / jdk1.7.0_60.jdk /内容/首页

running /usr/libexec/java_home gives: 运行/ usr / libexec / java_home给出:

/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home

running javac -version gives : 运行javac -version给出:

javac 1.7.0_60-ea javac 1.7.0_60-ea

running java -version gives: 运行java -version给出:

java version "1.7.0_60-ea" java版“1.7.0_60-ea”

Java(TM) SE Runtime Environment (build 1.7.0_60-ea-b15) Java(TM)SE运行时环境(版本1.7.0_60-ea-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode) Java HotSpot(TM)64位服务器VM(内置24.60-b09,混合模式)

In Android Studio I have set file->other settings->default project settings-> JDK location to the JDK location listed above. 在Android Studio中,我将文件 - >其他设置 - >默认项目设置 - > JDK位置设置为上面列出的JDK位置。

I've run out of options, why am I still getting this message? 我已经没有选择了,为什么我仍然收到这条消息?

thanks for any help, Ive wasted hours on this already. 谢谢你的帮助,我已经浪费了几个小时了。

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. 我发现同样的错误是由于Java Jar文件的冲突与Android Studio安装无关。 Specifically the tools.jar and auskey.jar under /Library/Java/Extensions More info here 在具体的tools.jar和位于/ Library / Java的/扩展更多信息auskey.jar 这里

Rich_LogicBox solution also worked for me. Rich_LogicBox解决方案也适合我。 I've struggled for weeks with different java versions making no difference. 我已经用不同的java版本挣扎了几个星期没有任何区别。 When I removed the jar files placed in /Library/Java/Extensions by auskey, the Android Studio error disappeared. 当我通过auskey删除放置在/ Library / Java / Extensions中的jar文件时,Android Studio错误消失了。

One possible solution is : 一种可能的解决方案是

The android studio needs the jdk 1.6+ by default, but your JDK is 1.7. Android工作室默认需要jdk 1.6+ ,但你的JDK是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. 您可以在Applications文件夹中show the package content Android Studio show the package content ,并打开info.plist ,将JVM version更改为您的JDK版本,此处为1.7 *

(you see, my JDK version is 1.8 in my computer) (你看,我的JDK版本在我的电脑中是1.8)

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM