30

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.

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:

Error message

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.

Update: This also applies to Yosemite, El Capitan, and all the other versions of OSX that can run Android Studio.

2

6 Answers 6

72

Update 12/11/2014 As of Android Studio 1.0 RC3 you can follow this set of directions to make it work.

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.

Location of file - you need to open it in the Applications folder Full resolution: https://i.sstatic.net/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.

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.

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.

2
  • 4
    For me, changing it to 1.8* did the trick. So you must probably change it to the latest JVMVersion
    – ejazz
    Commented Apr 16, 2014 at 6:58
  • 3
    You set it to whatever JDK major version you have. 1.8 didnt exist at the time.
    – Mgamerz
    Commented Apr 16, 2014 at 13:22
20

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+"

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)

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

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

Official instructions: 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)

2
  • Using the official jre from apple improves the font rendering. Thanks! Commented Jan 12, 2015 at 23:36
  • such a great answer !
    – Snicolas
    Commented May 29, 2015 at 3:32
3

mgamerz is right - The release notes give a much better solution for rc3 and onwards - theres a idea.properties file (or environment variable)

~/Library/Preferences/AndroidStudio/idea.properties

it also shows what environment variables you can use to set things like the jdk

export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk

ref : http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released

2
  • I created ~/Library/Preferences/AndroidStudio/idea.properties and in it have the path to my jdk : STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk No editing of the Info.plist necessary!
    – Uilleann
    Commented Jun 15, 2015 at 20:02
  • I am getting this Error:objc[985]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. any idea why its comming when run app?
    – Zeeshan
    Commented May 3, 2016 at 23:19
2

I did below command on Mac Terminal to fix this problem, please make sure java version and path.

$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
1

Hey Friends I just Figured it out a simple way to fix this for Mac users.

Open Terminal and type this -> java -version and hit enter.

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

Now there will be Content folder, Open that Folder and there you will find Info.plist

Open this info.plist And you will see this.

In this expand the 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)

So we need to change this number according to our jvm version, so i changed it to version 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.

Here is the Whole Docx file for Android Studio Setup in Mac X

LINK: https://www.dropbox.com/s/9jwjebn5hgydyll/Android%20Studio%20Setup%20on%20Mac.docx?dl=0

1
  • Works very well. Studio is one hell of a hack.
    – Gustav
    Commented Jan 21, 2015 at 8:44
0

I found that downloading an extra Java bundle from Apple fixed the issue.

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.

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

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.