Java Android Studio 无法找到有效的 Jvm(与 MAC OS 相关)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27369269/
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 was unable to find a valid Jvm (Related to MAC OS)
提问by iMickyRich
I am unable to start my Android Studio for Android development on Mac OS (10.10.1 - Yosemite)
我无法在 Mac OS (10.10.1 - Yosemite) 上启动我的 Android Studio 进行 Android 开发
采纳答案by hasternet
Open the application package for Android Studioin finder, and edit the Info.plistfile. Change the key JVMversion. Put 1.6+ instead of 1.6*. That worked for me!.
在finder中打开Android Studio的应用包,编辑Info.plist文件。更改密钥 JVMversion。用 1.6+ 代替 1.6*。这对我有用!
Cheers!
干杯!
Edited:
编辑:
While this was necessary in older versions of Android Studio, this is no longer recommended. See the official statement
虽然这在旧版本的 Android Studio 中是必要的,但不再推荐这样做。看官方声明
"Please note: Do not edit Info.plist to pick a different version. That will break not only the application signature, but also future patch updates to your installation."
“请注意:不要编辑 Info.plist 来选择不同的版本。这不仅会破坏应用程序签名,还会破坏您安装的未来补丁更新。”
Antonio Jose's answeris the correct one.
安东尼奥何塞的答案是正确的。
Thanks aried3r!
感谢 aried3r!
回答by Alonso C. Licks
Just install this guy here
只需在这里安装这个家伙
http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US
http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US
and you should be good.
你应该很好。
回答by Iggy
Edit the android studio's Info.plist file in the package so that it uses 1.7 or whatever JVMVersion you have installed. Changing the JVMVersion to 1.6+ instead of 1.6* as hasternet answered above should work too.
编辑包中 android studio 的 Info.plist 文件,使其使用 1.7 或您安装的任何 JVMVersion。将 JVMVersion 更改为 1.6+ 而不是 1.6* 作为上面回答的 hasternet 也应该有效。
The above works but is not recommended see RC3 Release Notes
以上工作但不推荐见RC3发行说明
As of RC 3, we have a better mechanism for customizing properties for the launchers on all three platforms. You should not edit any files in the IDE installation directory. Instead, you can customize the attributes by creating your own .properties or .vmoptions files in the following directories. (This has been possible on some platforms before, but it required you to copy and change the entire contents of the files. With the latest changes these properties are now additive instead such that you can set just the attributes you care about, and the rest will use the defaults from the IDE installation).
从 RC 3 开始,我们有了更好的机制来为所有三个平台上的启动器自定义属性。您不应编辑 IDE 安装目录中的任何文件。相反,您可以通过在以下目录中创建自己的 .properties 或 .vmoptions 文件来自定义属性。(这在之前的一些平台上是可能的,但它需要您复制和更改文件的全部内容。随着最新的更改,这些属性现在是可添加的,这样您就可以只设置您关心的属性,其余的将使用 IDE 安装中的默认值)。
see Android Studio failed to load JVM on Mac OSX (Mavericks)
回答by Magster
Change this key in the Info.plist
在 Info.plist
I changed from
我从
<key>JVMVersion</key>
<string>1.6*</string>
to
到
<key>JVMVersion</key>
<string>1.8*</string>
and it worked fine now..
现在它运行良好..
Edited:
Per the official statement as mentioned above by hasternet and aried3r, the solution by Antonio Jose is correct.
编辑:
根据hasternet和aried3r上面提到的官方声明,Antonio Jose的解决方案是正确的。
Thanks!
谢谢!
回答by Antonio Jose
[Update]
This is fixed in Android Studio 1.1
https://issuetracker.google.com/issues/37015035
[更新]
这已在 Android Studio 1.1 https://issuetracker.google.com/issues/37015035 中修复
In the next version of Android Studio, if no java 6 is found but 7 (or greater) is found then it will use that instead. We still recommend running studio with Java 6 due to improved font rendering, but there is no work around needed if, for example, only java 8 is found.
在下一版本的 Android Studio 中,如果没有找到 java 6 但找到了 7(或更高版本),那么它将改用它。由于改进了字体渲染,我们仍然建议使用 Java 6 运行 studio,但如果例如只找到 java 8,则不需要解决方法。
[End Update]
【结束更新】
From Android Studio 1.0 RC3 Notes
As of RC 3, we have a better mechanism for customizing properties for the launchers on all three platforms. You should not edit any files in the IDE installation directory. Instead, you can customize the attributes by creating your own .properties or .vmoptions files in the following directories. (This has been possible on some platforms before, but it required you to copy and change the entire contents of the files. With the latest changes these properties are now additive instead such that you can set just the attributes you care about, and the rest will use the defaults from the IDE installation).
从 RC 3 开始,我们有了更好的机制来为所有三个平台上的启动器自定义属性。您不应编辑 IDE 安装目录中的任何文件。相反,您可以通过在以下目录中创建自己的 .properties 或 .vmoptions 文件来自定义属性。(这在某些平台上以前是可能的,但它需要您复制和更改文件的全部内容。通过最新的更改,这些属性现在是附加的,这样您就可以只设置您关心的属性,其余的将使用 IDE 安装中的默认值)。
However there is no explanation about what options are.
但是,没有解释什么是选项。
After searching a little I found this
Adjusting VM Options for Android Studio on Mac
IntelliJ IDEA 14.0.0 Web Help/File IDEA.Properties
经过一番搜索后,我发现了这个
在 Mac IntelliJ IDEA 14.0.0 Web 帮助/文件 IDEA.Properties上为 Android Studio 调整 VM 选项
However no luck with that.
然而,没有运气。
Fortunately I was able to resolve it on Yosemite using environment variables as said in the 1.0 RC3 Release Notes.
幸运的是,我能够使用环境变量在 Yosemite 上解决它,如 1.0 RC3 发行说明中所述。
You can also place use environment variables to point to specific override files elsewhere:
STUDIO_VM_OPTIONS, which vmoptions file to use
STUDIO_PROPERTIES, which property file to use
STUDIO_JDK, which JDK to run studio with
您还可以将使用环境变量指向其他地方的特定覆盖文件:
STUDIO_VM_OPTIONS,哪个 vmoptions 文件使用
STUDIO_PROPERTIES,哪个属性文件使用
STUDIO_JDK,哪个 JDK 运行工作室
This was a little tricky because Android Studio is not a command line application so I had to use a AppleScript command to set the environment variable when login. More info here
这有点棘手,因为 Android Studio 不是命令行应用程序,所以我必须在登录时使用 AppleScript 命令来设置环境变量。更多信息在这里
This is my launchctl command for the command line.
这是我用于命令行的 launchctl 命令。
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
And this my AppleScript (remember to save it as an Application)
这是我的 AppleScript(记得将其另存为应用程序)
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
About launchctl, see here
关于launchctl,请看这里
回答by luongnv89
I am using Mac OS X 10.10 also. And to fix this problem.
我也在使用 Mac OS X 10.10。并解决这个问题。
- Open Android Studio application package content (by right click on Android Studio icon in Application folder)
- Open file Infor.plist
Search and replace:
<key> JVM version</key> <string>1.6*</string>
- 打开 Android Studio 应用程序包内容(通过右键单击 Application 文件夹中的 Android Studio 图标)
- 打开文件 Infor.plist
搜索和替换:
<key> JVM version</key> <string>1.6*</string>
replaced by:
取而代之:
<key> JVM version</key>
<string>1.6+</string>
That's it!
就是这样!
回答by Zafua
I have same problem and fixed with this way:
我有同样的问题并通过这种方式修复:
You should install Java from Official Apple page.
您应该从 Apple 官方页面安装 Java。
回答by Roger Suen
On Android Tools Project Site, there is a great explanation Mac OSX JDK Selection. It fixed my problem. In summary:
在 Android Tools Project Site 上,有一个很好的解释Mac OSX JDK Selection。它解决了我的问题。总之:
Android Studio requires two different JDKs:
- The version of Java that the IDE itself runs with.
- The version of the JDK that it uses to get the Java compiler from
These two can be (and usually are) the same, but you can configure them individually. And on OSX in particular, they will often be different.
Android Studio 需要两个不同的 JDK:
- IDE 本身运行的 Java 版本。
- 用于从中获取 Java 编译器的 JDK 版本
这两个可以(通常是)相同,但您可以单独配置它们。特别是在 OSX 上,它们通常会有所不同。
and for Yosemite (Mac OSX 10.10) Issues:
和优胜美地 (Mac OSX 10.10) 问题:
First, please make sure that you have the latest version of Java 6 installed; in some cases that has fixed the problems: http://support.apple.com/kb/DL1572
If not, try running a recent version of Java 7 or Java 8 instead by setting STUDIO_JDK as described above. That is reported to have fixed the other problems (though you will get the font rendering shown for Java 8 above.)
首先,请确保您安装了最新版本的 Java 6;在某些情况下已经解决了问题:http: //support.apple.com/kb/DL1572
如果没有,请尝试运行 Java 7 或 Java 8 的最新版本,方法是如上所述设置 STUDIO_JDK。据报道,这已经解决了其他问题(尽管您将获得上面为 Java 8 显示的字体渲染。)
回答by Govind
Note that this last variable allows you to for example run Android Studio with Java 7 on OSX (which normally picks Java 6 from the version specified in Info.plist):
请注意,最后一个变量允许您例如在 OSX 上使用 Java 7 运行 Android Studio(通常从 Info.plist 中指定的版本中选择 Java 6):
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
$ open /Applications/Android\ Studio.app
$ 打开 /Applications/Android\ Studio.app
Worked for me
为我工作
回答by Rozen
This one work for me, very simple, just export the environmentable var. but make sure u have the valid JVM first though.
这对我有用,非常简单,只需导出环境变量即可。但请确保您首先拥有有效的 JVM。