无法在优胜美地运行 Android Studio

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24124911/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:49:26  来源:igfitidea点击:

Can't run Android Studio on Yosemite

androidandroid-studioosx-yosemite

提问by Rob

Can't install Java 7 (installer refuses).

无法安装 Java 7(安装程序拒绝)。

Can install Java 8.

可以安装Java 8。

But then starting Android Studio, it says it needs to install the legacy JDK 6, which is not going to work for me because our projects are already 1.7.

但是然后启动 Android Studio,它说它需要安装旧版 JDK 6,这对我不起作用,因为我们的项目已经是 1.7。

采纳答案by Tor Norbye

We now have an official page describing what to do: http://tools.android.com/tech-docs/configuration/osx-jdk

我们现在有一个官方页面描述要做什么:http: //tools.android.com/tech-docs/configuration/osx-jdk

Please, please don't edit Info.plist; that has many downsides (including broken patches and application signatures breaking etc). As of Android Studio 1.0 we have a different way of setting the JDK to be used by the IDE.

请不要编辑Info.plist;这有很多缺点(包括损坏的补丁和破坏应用程序签名等)。从 Android Studio 1.0 开始,我们有一种不同的方式来设置 IDE 使用的 JDK。

回答by Jerry Tian

UPDATE 2014.12.10

更新 2014.12.10

This should be the final update on this question.

这应该是关于这个问题的最终更新。

After the final release of Android Studio v1.0, there is an official way to select your JVM, mentioned here:

在 Android Studio v1.0 最终发布之后,官方提供了一种选择 JVM 的方法,这里提到:

http://tools.android.com/tech-docs/configuration/osx-jdk

http://tools.android.com/tech-docs/configuration/osx-jdk

All the following information is kept only as reference, please don't use it.

以下所有信息仅供参考,请勿使用。

UPDATE 2014.11.26

更新 2014.11.26

Editing the Info.plistfile as suggested in this answer might break your IDE.
Please check out the prescribed solutionmentioned by the IntelliJ folks, and this is the prefered fix to this problem.

Info.plist按照此答案中的建议编辑文件可能会破坏您的 IDE
请查看IntelliJ 人员提到的规定解决方案,这是解决此问题的首选方法。

If any of the misbehavior/undesired effects mentioned there happen with your setup by using this fix, you should restore the plist file, and use the legacy JDK 6 instead.

如果使用此修复程序在您的设置中发生了其中提到的任何不当行为/不良影响,您应该恢复 plist 文件,并改用旧版 JDK 6。

If JDK 6 is not an option for your setup, or still have some difficulty to start up the IDE, you can try this fix at your own risk.

如果 JDK 6 不是您的设置选项,或者在启动 IDE 时仍有一些困难,您可以自担风险尝试此修复程序。

Please also read the commentsunder this answer to review feedbacks from other community members(yes, good and bad) and my discussions with them.

另请阅读此答案下的评论,以查看其他社区成员的反馈(是的,好的和坏的)以及我与他们的讨论。

OLDER UPDATE

较旧的更新

This is an outdated answer, when Yosemite is in early Beta stage and could mess your current setup(see the comments, mostly caused by incompatible JVMs when you do need to update/upgrade them).

这是一个过时的答案,当 Yosemite 处于早期 Beta 阶段并且可能会弄乱您当前的设置(请参阅评论,主要是由于 JVM 不兼容而导致您确实需要更新/升级它们)。

As mentioned in the original answer, this is a "dirty" fix that time, and the most suitable way to fix this problem now is to upgrade/update your JVMs as suggested for your OSX system.

正如原始答案中所述,当时这是一个“肮脏”的修复,现在解决此问题的最合适方法是按照OSX 系统的建议升级/更新 JVM

Original answer is put below just for reference, if all the JVM upgrade/update still doesn't work for you, at least you can manually install a JVM and use this hack, but please don't upvote this answer because there are better ones.

原始答案仅供参考,如果所有 JVM 升级/更新仍然不适合您,至少您可以手动安装 JVM 并使用此 hack,但请不要对这个答案投赞成票,因为有更好的答案.

==================================

==================================

As mentioned as other users, the JDK from Apple and new OSX seems mess things up.

正如其他用户所提到的,来自 Apple 的 JDK 和新的 OSX 似乎把事情搞砸了。

However, there is a dirty quick fix for it.

但是,有一个肮脏的快速修复方法。

First, locate your Android Studio, for my machine, it is here:

首先,找到你的 Android Studio,对于我的机器,它在这里:

jerry-retina-mbp:Android Studio.app jerry$ pwd
/Applications/Android Studio.app

Then find the application bundle description file for it, named "Info.plist":

然后找到它的应用程序包描述文件,名为“Info.plist”:

jerry-retina-mbp:Android Studio.app jerry$ ls Contents/Info.plist 
Contents/Info.plist

Use "Finder" to open this folder:

使用“Finder”打开这个文件夹:

jerry-retina-mbp:Android Studio.app jerry$ open Contents

Then, you can use whatever text editor you like, to modify the JVM settings in "Info.plist"(which is just a XML file).

然后,您可以使用任何您喜欢的文本编辑器来修改“Info.plist”(它只是一个 XML 文件)中的 JVM 设置。

Before:

前:

  <key>JVMVersion</key>
  <string>1.6*</string>

After:

后:

  <key>JVMVersion</key>
  <string>1.6+</string>

Hopefully after this change, your Android Studio will not complain the JVM again.

希望在此更改之后,您的 Android Studio 不会再次抱怨 JVM。

回答by Silmaril

If you click "more..." on error dialog it will lead to Java for OS X 2014-001. Just download and install it.

如果您在错误对话框中单击“更多...”,它将导致Java for OS X 2014-001。只需下载并安装它。

回答by Luke Sleeman

I followed the top voted answer, under the final retail version of Yosemite, with android studio 0.8.9 and it caused loads of issues - My multi-monitor setup wouldn't work, and android studio would randomly crash or lock up.

我遵循了优胜美地最终零售版本中投票最高的答案,使用 android studio 0.8.9,它导致了很多问题 - 我的多显示器设置不起作用,android studio 会随机崩溃或锁定。

Instead what worked for me was to install the java update at: http://support.apple.com/kb/DL1572

相反,对我有用的是在以下位置安装 java 更新:http: //support.apple.com/kb/DL1572

InteliJ do not recommend editing the plist file, to run the IDE under a higher version of java. It will break the updating system. In addition there are many bugs which will appear when running under higher versions of java: https://intellij-support.jetbrains.com/entries/27854363-IDE-doesn-t-start-after-updating-to-Mac-OS-Yosemite-or-Mavericks

InteliJ 不建议编辑 plist 文件,在更高版本的 java 下运行 IDE。它会破坏更新系统。另外在高版本java下运行会出现很多bug:https: //intellij-support.jetbrains.com/entries/27854363-IDE-doesn-t-start-after-updating-to-Mac-OS -优胜美地或小牛队

回答by Yassine ABID

I had the same issue and I fixed by installing javaforosx. http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US. ;)

我遇到了同样的问题,我通过安装 javaforosx 解决了这个问题。http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US。;)

回答by Lavare

Open a terminal and run

打开终端并运行

java -version

If it shows javac 1.8.*, then

如果显示javac 1.8.*,则

<key>JVMVersion</key>
<string>1.8*</string>

otherwise (javac 1.7.*), then

否则 ( javac 1.7.*),则

<key>JVMVersion</key>
<string>1.7*</string>

If there is no display at all, you should install Java SDK.

如果根本没有显示,您应该安装Java SDK。

回答by MIGUEL ANGEL ALONSO PEREZ

I've tried several solutions, downloading several sdk but Android Studio didn't recognize them as valid sdks.

我尝试了几种解决方案,下载了几个 sdk,但 Android Studio 无法将它们识别为有效的 sdk。

Finally, the workaround that worked for me was:

最后,对我有用的解决方法是:

  1. Delete "Android Studio.app" and Android Studio preferences (~/Library/Preferences/AndroidStudio).
  2. Rename /usr/libexec/java_home to java_home.bak.
  3. Install again Android Studio.
  4. When Android Studio prompts for a valid Java SDK, follow link provided by Android Studio and download that java installation.
  5. After installation, push detect button on Android Studio, and run.
  1. 删除“Android Studio.app”和 Android Studio 首选项 (~/Library/Preferences/AndroidStudio)。
  2. 将 /usr/libexec/java_home 重命名为 java_home.bak。
  3. 再次安装 Android Studio。
  4. 当 Android Studio 提示输入有效的 Java SDK 时,请按照 Android Studio 提供的链接下载该 Java 安装。
  5. 安装完成后,在 Android Studio 上按检测按钮,然后运行。

回答by Gibran E Castillo

Last year I uninstalled Java 6 from Mavericks and installed Java 7, then I install Android Studio and everything was working fine. I upgraded Android Studio sometime around August or October and I started having the problem everyone is having. Today, I uninstalled Java 7 and installed Java 8 and added the STUDIO_JDK for Java 8. I uninstalled Android Studio and installed the latest version of Android Studio. Now, everything is working like is supposed to.

去年我从 Mavericks 卸载了 Java 6 并安装了 Java 7,然后我安装了 Android Studio,一切正常。我在 8 月或 10 月左右的某个时候升级了 Android Studio,我开始遇到每个人都遇到的问题。今天,我卸载了Java 7并安装了Java 8并添加了Java 8的STUDIO_JDK。我卸载了Android Studio并安装了最新版本的Android Studio。现在,一切都像预期的那样工作。

回答by Rob

Got this all to work:

让这一切正常工作:

  • installed the legacy JDK
  • installed JDK 8
  • 安装了旧版 JDK
  • 安装了 JDK 8

Found a thread that Oracle is going to update 1.7 so that the installer will not balk at 10.10 but that was not out yet.

发现 Oracle 将更新 1.7 以便安装程序不会在 10.10 犹豫不决的线程,但尚未发布。

This ended up working. Clearly the app itself is using 8 since my language level in my project is set to 1.7 and the legacy JDK is 1.6.

这最终奏效了。显然,应用程序本身使用的是 8,因为我在项目中的语言级别设置为 1.7,而旧版 JDK 为 1.6。

回答by luciano.bustos

for me the solution was:

对我来说,解决方案是:

  1. Open the Info.plist file inside Android Studio.app Folder. (use show package contents context menu)
  2. Find the key JVMVersionand replace the below version number string with 1.8*.
  3. Save
  1. 打开 Android Studio.app 文件夹中的 Info.plist 文件。(使用显示包内容上下文菜单)
  2. 找到密钥JVMVersion并将以下版本号字符串替换为1.8*
  3. 节省

XML Info.plist should look like this

XML Info.plist 应如下所示

<key>JVMVersion</key>
<string>1.8*</string>

This Also works on Android Studio 0.9.9

这也适用于 Android Studio 0.9.9