Can't run Android Studio on Yosemite

2019-01-21 11:03发布

问题:

Can't install Java 7 (installer refuses).

Can install 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.

回答1:

We now have an official page describing what to do: 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.



回答2:

UPDATE 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:

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

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

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.

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.

Please also read the comments under 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).

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.

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.

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

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

However, there is a dirty quick fix for it.

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

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

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

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

Use "Finder" to open this folder:

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).

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.



回答3:

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



回答4:

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.

Instead what worked for me was to install the java update at: 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



回答5:

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



回答6:

Open a terminal and run

java -version

If it shows javac 1.8.*, then

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

otherwise (javac 1.7.*), then

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

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



回答7:

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

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.


回答8:

Got this all to work:

  • installed the legacy JDK
  • installed 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.

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.



回答9:

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 JVMVersion and replace the below version number string with 1.8*.
  3. Save

XML Info.plist should look like this

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

This Also works on Android Studio 0.9.9



回答10:

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.