Java Android Studio 无法在 Mac OSX (Mavericks) 上加载 JVM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20925253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Studio failed to load JVM on Mac OSX (Mavericks)
提问by Mgamerz
I am trying to setup Android Studio on my Mac. It is running OSX 10.9.1 Mavericks. I have installed the latest JDK (at the time of writing 1.7 update 45), and I installed Android Studio. I use Java 7 because I have some Java applications I have to run and they require 1.7. I have not installed Java 1.6, because it is ancient and old. Launching Android Studio from any launcher does literally nothing. Activity Manager never shows it running. I do not want to install Java 1.6.
我正在尝试在我的 Mac 上设置 Android Studio。它运行的是 OSX 10.9.1 Mavericks。我已经安装了最新的 JDK(在撰写 1.7 更新 45 时),并且我安装了 Android Studio。我使用 Java 7,因为我必须运行一些 Java 应用程序,它们需要 1.7。我没有安装Java 1.6,因为它是古老而古老的。从任何启动器启动 Android Studio 几乎没有任何作用。活动管理器从不显示它正在运行。我不想安装 Java 1.6。
I did some work and tried to run the executable via command line through the package contents, and for both executables, I get these messages:
我做了一些工作并尝试通过命令行通过包内容运行可执行文件,对于这两个可执行文件,我收到以下消息:
I am unsure what I am supposed to do to fix this error. I'm not very adept on a Mac (still somewhat new to it, and its confusing to do power user stuff on this) so if anyone can help me figure it out that'd be great. I'm on the 2013 Macbook Air with plenty of resources for this to run.
我不确定我应该怎么做才能解决这个错误。我在 Mac 上不是很熟练(对它还是有些陌生,并且在这方面做高级用户的东西很令人困惑)所以如果有人能帮我弄清楚那会很棒。我在 2013 年的 Macbook Air 上有很多资源可以运行。
Update: This also applies to Yosemite, El Capitan, and all the other versions of OSX that can run Android Studio.
更新:这也适用于 Yosemite、El Capitan 和所有其他可以运行 Android Studio 的 OSX 版本。
采纳答案by Mgamerz
Update 12/11/2014As of Android Studio 1.0 RC3 you can follow this set of directionsto make it work.
2014 年 12 月 11 日更新从 Android Studio 1.0 RC3 开始,您可以按照这组说明进行操作。
I figured it out. You have to edit the android studio's Info.plist file in the package so it uses 1.7. I don't get why Android Studio insists we install and use an outdated, vulnerable version of Java.
我想到了。您必须在包中编辑 android studio 的 Info.plist 文件,以便它使用 1.7。我不明白为什么 Android Studio 坚持要我们安装和使用过时的、易受攻击的 Java 版本。
Full resolution: http://i.stack.imgur.com/yyYaG.png
完整分辨率:http: //i.stack.imgur.com/yyYaG.png
To open the package you need to find the Android Studio.app file in the Applications folder and right click it > Show Package Contents.
要打开包,您需要在 Applications 文件夹中找到 Android Studio.app 文件,然后右键单击它 > Show Package Contents。
Edit the plist (I think you might need to be root) and change JVMVersion from 1.6* to 1.7* (or 1.8*, or whatever JDK major version you have). I don't get why that made a difference since my original output said it was using 1.7 anyways.
编辑 plist(我认为您可能需要成为 root)并将 JVMVersion 从 1.6* 更改为 1.7*(或 1.8*,或您拥有的任何 JDK 主要版本)。我不明白为什么这会有所不同,因为我的原始输出说它无论如何都使用 1.7。
This fix seems to apply to all of IntelliJ's IDEs (I've seen it on PyCharm as well), though other ones seem to support newer versions of java natively.
这个修复似乎适用于所有 IntelliJ 的 IDE(我也在 PyCharm 上看到过),尽管其他的似乎原生支持较新版本的 java。
回答by Tim Marsh
mgamerz is right - The release notes give a much better solution for rc3 and onwards - theres a idea.properties file (or environment variable)
mgamerz 是对的 - 发行说明为 rc3 及以后版本提供了更好的解决方案 - 有一个 idea.properties 文件(或环境变量)
~/Library/Preferences/AndroidStudio/idea.properties
~/Library/Preferences/AndroidStudio/idea.properties
it also shows what environment variables you can use to set things like the jdk
它还显示了您可以使用哪些环境变量来设置 jdk 之类的内容
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
ref : http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released
参考:http: //tools.android.com/recent/androidstudio1rc3_releasecandidate3released
回答by Zael
As answered by hasternet @ Android Studio was unable to find a valid Jvm (Related to MAC OS)For quick and dirty solution, Follow the answer by Mgamerz; open Android Studio in Finder (CTRL+Click > Show Package Contests > Contents > info.plist) and edit Key JVMOptions>JVMVersion from "1.6*" to "1.6+"
正如 hasternet @ Android Studio所回答的那样,无法找到有效的 Jvm(与 MAC OS 相关)对于快速而肮脏的解决方案,请按照 Mgamerz 的回答进行操作;在 Finder 中打开 Android Studio(CTRL+Click > Show Package Contests > Contents > info.plist)并编辑 Key JVMOptions>JVMVersion 从“1.6*”到“1.6+”
Recommended method as discovered by Antonio Jose is to edit environment variables in MacOS (messing with info.plist is not recommended) either at program launch (opening the Studio through terminal rather than the icon)
Antonio Jose 发现的推荐方法是在程序启动时(通过终端而不是图标打开 Studio)在 MacOS 中编辑环境变量(不推荐使用 info.plist)
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
$ open /Applications/Android\ Studio.app
or setting up the environment through AppleScript at every MacOS startup:
或者在每次 MacOS 启动时通过 AppleScript 设置环境:
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
do shell script "launchctl setenv STUDIO_PROPERTIES /Users/username/Library/Preferences/AndroidStudio/idea.properties"
do shell script "launchctl setenv STUDIO_VM_OPTIONS /Users/username/Library/Preferences/AndroidStudio/studio.vmoptions"
(Remember to save the script as Application. Antonio Jose managed with just the first line - AFAIK you can use .properties and .vmoptions to set up additional settings.)
(记住将脚本保存为应用程序。Antonio Jose 只用第一行管理 - AFAIK 您可以使用 .properties 和 .vmoptions 来设置其他设置。)
Official instructions: http://tools.android.com/tech-docs/configuration/osx-jdk
官方说明:http: //tools.android.com/tech-docs/configuration/osx-jdk
(The reason why Android Studio want's to run off of JRE 1.6 is because it apparently makes the fonts look better - feel free to go through that "official" route and install JRE 1.6 @ http://support.apple.com/kb/DL1572- you can then set the JDK to 1.8 in the SDK Location settings - local.properties)
(Android Studio 想要运行 JRE 1.6 的原因是因为它显然使字体看起来更好 - 随意通过“官方”路线并安装 JRE 1.6 @ http://support.apple.com/kb/ DL1572- 然后您可以在 SDK 位置设置中将 JDK 设置为 1.8 - local.properties)
回答by SMIT N.DOSHI
Hey Friends I just Figured it out a simple way to fix this for Mac users.
嘿朋友们,我刚刚想出了一个简单的方法来为 Mac 用户解决这个问题。
Open Terminal and type this -> java -version and hit enter.
打开终端并输入此 -> java -version 并按回车键。
Output will be something like this:
输出将是这样的:
Now check your Java Version. My Java version is 1.8 So now we need to Open Contents of our Android App. For that right click the Android.app and then select Show Contents Like this
现在检查您的 Java 版本。我的 Java 版本是 1.8 所以现在我们需要打开我们的 Android 应用程序的内容。为此,右键单击 Android.app,然后选择像这样显示内容
Now there will be Content folder, Open that Folder and there you will find Info.plist
现在会有 Content 文件夹,打开那个文件夹,你会在那里找到 Info.plist
Open this info.plist And you will see this.
打开这个 info.plist 你会看到这个。
In this expand the JVM
在此展开JVM
Here you will see the JVM version showing 1.6* but our jvm version is 1.8 (for example my jvm version is 1.8)
在这里您将看到 JVM 版本显示为 1.6* 但我们的 jvm 版本是 1.8(例如我的 jvm 版本是 1.8)
So we need to change this number according to our jvm version, so i changed it to version 1.8*
所以我们需要根据我们的 jvm 版本改变这个数字,所以我把它改成了 1.8*
Then click save. And you are done. Now you will see setup wizard running
然后点击保存。你已经完成了。现在您将看到安装向导正在运行
And you are ready to start your first android programming app.
您已准备好开始您的第一个 android 编程应用程序。
Here is the Whole Docx file for Android Studio Setup in Mac X
这是 Mac X 中 Android Studio 设置的整个 Docx 文件
LINK: https://www.dropbox.com/s/9jwjebn5hgydyll/Android%20Studio%20Setup%20on%20Mac.docx?dl=0
链接:https: //www.dropbox.com/s/9jwjebn5hgydyll/Android%20Studio%20Setup%20on%20Mac.docx?dl =0
回答by simon_smiley
I found that downloading an extra Java bundle from Apple fixed the issue.
我发现从 Apple 下载额外的 Java 包解决了这个问题。
If you search for this problem then I found the second link was to a blog having exactly this problem, all credit goes to him here
如果你搜索这个问题,后来我发现第二个环节是正好具有这个问题的博客,都归功于他在这里
I know that posting links isn't an answer but as you can see from the resolution you need to make sure you have an up to date version of Java and also the Java bundle from Apple, for this reason I have also included the searches needed to get to these websites.
我知道发布链接不是答案,但正如您从解决方案中看到的,您需要确保您拥有最新版本的 Java 以及来自 Apple 的 Java 包,因此我还包括了所需的搜索访问这些网站。
Here is where to download the latest version of Java
If this link is broken then searching "java latest version" return it at the top of the Google list
如果此链接已损坏,则搜索“java 最新版本”将其返回到 Google 列表的顶部
Here is where to download the Apple Bundle
If this link is broken then searching "Java for OS X 2014-001" returns it at the top of the Google list
如果此链接断开,则搜索“Java for OS X 2014-001”会在 Google 列表的顶部返回
For me trying to solve this problem it appears that initially it was an issue that required a work around and then Apple released an official work around download meaning that fiddling in plists is not necessary any more.
对我来说,试图解决这个问题似乎最初是一个需要解决的问题,然后 Apple 发布了一个官方的解决方法下载,这意味着不再需要摆弄 plist。
回答by Powen Ko
I did below command on Mac Terminal to fix this problem, please make sure java version and path.
我在 Mac 终端上做了以下命令来解决这个问题,请确保 java 版本和路径。
$java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
$ open /Applications/Android\ Studio.app