Reputation: 2243
I am unable to start my Android Studio for Android development on Mac OS (10.10.1 - Yosemite)
Upvotes: 211
Views: 148262
Reputation: 3596
Open the application package for Android Studio in finder, and edit the Info.plist file. Change the key JVMversion. Put 1.6+ instead of 1.6*. That worked for me!.
Edited:
While this was necessary in older versions of Android Studio, this is no longer recommended. See the official statement
"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."
Antonio Jose's answer is the correct one.
Thanks aried3r!
Upvotes: 354
Reputation: 2778
[Update]
This is fixed in 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.
[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).
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
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.
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
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
This is my launchctl command for the command line.
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
And this my AppleScript (remember to save it as an Application)
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
About launchctl, see here
Upvotes: 140
Reputation: 631
Set envirionment variable STUDIO_JDK
(java_home
outputs the Java home dir and sed
strips two folders to get the jdk dir)
launchctl setenv STUDIO_JDK `/usr/libexec/java_home -version 1.8 | sed 's/\/Contents\/Home//g'`
Launch Android Studio like you would normally
The above steps only works for the current session. Here is how to create a plist file in /Library/LaunchDaemons that runs the above command on every boot:
sudo defaults write /Library/LaunchDaemons/com.google.studiojdk Label STUDIO_JDK
sudo defaults write /Library/LaunchDaemons/com.google.studiojdk ProgramArguments -array /bin/launchctl setenv STUDIO_JDK `/usr/libexec/java_home | sed 's/\/Contents\/Home//g'`
sudo defaults write /Library/LaunchDaemons/com.google.studiojdk RunAtLoad -bool TRUE
Found out about the plist trick thanks to http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-launchd-plist/
Upvotes: 5
Reputation: 3938
Java was uninstalled when I updated to OS X El Capitan.
See screenshot of terminal before and after I reinstalled Java.
To reinstall Java I followed this link that was provided in the Android Studio dialog box.
Android Studio ran again after the Java installation was reinstalled.
Upvotes: 2
Reputation: 506
Android Studio will read settings from the file ~/Library/Preferences/AndroidStudio/idea.properties. I created this file 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!
Upvotes: 1
Reputation: 41
I had previously uninstall Java 6 and install Java 7, Android Studio was working okay, then I upgraded Android Studio and I had the issue everyone is having. Today, I uninstalled Java 7 and installed Java 8 from Oracle. Then I uninstall Android Studio and installed the latest. Everything is working for me now
Upvotes: 0
Reputation: 13657
Try downloading the Java from Apple Support Page: http://support.apple.com/kb/DL1572 if that doesn't work for you or fails to load (very common issue), just follow this link to download and install the Java version you need:
http://support.apple.com/downloads/DL1572/en_US/JavaForOSX2014-001.dmg
That's it.
Upvotes: 0
Reputation: 7089
As @Gerard suggested, I summerise my original comment (https://stackoverflow.com/a/27370525/763459) as an Answer, hope it can help others who are annoyed by this issue.
There's a way without running the AppleScript:
edit .bash_profile
(if this file doesn't exist, please create a new one , as @Gerard suggested, you can to use source .bash_profile
for the first time).
Install the legacy Java (may be neccessary) http://support.apple.com/kb/DL1572
Put export STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk
Then quit terminal (or any text editors you're using to edit this file), run the Android Studio and viola
Tested with OSX 10.10 and Android 1.0.1
Upvotes: 1
Reputation: 1222
Do not edit the plist. These instructions worked for me the first time I installed Android Studio a few months ago as well as just today. (1/21/2015)
All you need to do is a few simple things, although they aren't really listed on Google's website.
Upvotes: 1
Reputation: 1
For those who were having trouble creating a script that launched on startup, as an alternative you can add this .plist to your LaunchAgents folder. This may be a more appropriate way of adding environment variables to the system since Yosemite decided to do away with launchd.conf. This should also work across user accounts due to the nature of the LaunchAgents folder, but I haven't tested that.
To do this, create a .plist file with the following name and path:
/Library/LaunchAgents/setenv.STUDIO_JDK.plist
and the contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.STUDIO_JDK</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
<key>LaunchOnlyOnce</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
Then change file properties by running the following commands in Terminal:
sudo chmod 644 /Library/LaunchAgents/setenv.STUDIO_JDK.plist
sudo chown root /Library/LaunchAgents/setenv.STUDIO_JDK.plist
sudo chgrp wheel /Library/LaunchAgents/setenv.STUDIO_JDK.plist
Notes:
1) You may need to change 'jdk1.8.0_25.jdk' to match the version that you have on your computer.
2) I tried to use "jdk1.8.*.jdk" to try and account for varying Java * versions, but when I opened Android Studio I got the no JVM error even though if you run "echo $STUDIO_JDK" it returns the correct path. Perhaps someone has some insight as to how to fix that issue.
Upvotes: 0
Reputation: 11699
You can implement the STUDIO_JDK
solution using your user's launch agents. This involves creating one plist file in your LaunchAgents directory, located at ~/Library/LaunchAgents
Create a new file, ~/Library/LaunchAgents/UNIQUE_KEY.plist
, where UNIQUE_KEY is just an identifier. I use com.username.androidstudio.
Copy the following text into your new plist file and modify it according the instructions below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>UNIQUE_KEY</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
You will need to make two modifications:
This is the same underlying solution as Antonio Jose's answer. It sets the STUDIO_JDK environment variable based on the Android Studio version 1.0 RC3 release notes. This solution uses the LaunchAgents directory rather than AppleScript to set the environment variable. As such it is mostly a difference in how your order and organize your system and environment variables.
Upvotes: 1
Reputation: 6416
As a novice user it took me a while to understand how to fix this in a correct way. After searching and understating many answers on SO I came out with the Following steps that you need to follow to fix the issue.
Please Note:
Although the simplest solution is to update the Info.plist of android studio . But it is not recommended and not the correct way to fix it .
Official statement- "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."
First Solution : If you run your Android Studio from command line, you can add these two lines into your .bash_profile
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
$ open /Applications/Android\ Studio.app
From next time whenever you open your terminal your studio will start automatically.
Second Solution: If you want to run Android Studio from UI(by click on Icon) follow below steps:
Copy past the below line
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
Note :- Change the jdk version according to your version. To check which version you are using open terminal and run the following command
java -version
3.Now save (⌘+s) as File format: Application. Finally open System Settings → Users & Groups → Login Items and add your new application that you have just created.
woolaaaa…Its done.
References :
Upvotes: 12
Reputation: 59
i'm dealing with the same problem and i get it worked.
it is probably that your jdk version is not right.
now i installed jdk1.8 and it is ok now.
Upvotes: 0
Reputation: 1
I was able to get it to work by editing the info.plist changing 16* to 16+. Tried using the recommended method but that failed.
Upvotes: -1
Reputation: 136
I ran this bad boy:
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/
Upvotes: 0
Reputation: 1310
I resolved this issue by changing the JVM version in the Info.plist file to 1.7*
Upvotes: 0
Reputation: 517
I have downloaded Intellij Idea. When I try to install Intellij, a pop-up appeared that my Mac is missing with Java RE, do you want to download it? After I downloaded missing package using Intellij, I could open Android Studio.
Upvotes: 0
Reputation: 11
On Mac OS X Yosemite just install:
Java SE Development Kit 8
and
Java Version 8 Update 25
It's all, work for me too! like gehev said , so simple !
Upvotes: 1
Reputation: 61
On Mac OS X Yosemite just install:
Java SE Development Kit 8
and
Java Version 8 Update 25
It's all, work for me!
Upvotes: 6
Reputation: 1
"On Mac OS, run Android Studio with Java Runtime Environment (JRE) 6 for optimized font rendering. You can then configure your project to use Java Development Kit (JDK) 6 or JDK 7."
This was listed in http://developer.android.com/sdk/index.html under the system requirements for Mac OS X.
Once you install Java 6 (not the JDK) from Apple as per Alonso C. Licks, you should be able to open Android Studio and reconfigure as you wish without having to mess around in the terminal, info.plist file, or other libraries.
Upvotes: 0
Reputation: 139
This one work for me, very simple, just export the environmentable var. but make sure u have the valid JVM first though.
https://code.google.com/p/android/issues/detail?id=82378
Upvotes: 1
Reputation: 311
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):
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
$ open /Applications/Android\ Studio.app
Worked for me
Upvotes: 21
Reputation: 51
On Android Tools Project Site, there is a great explanation Mac OSX JDK Selection. It fixed my problem. In summary:
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.
and for Yosemite (Mac OSX 10.10) Issues:
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.)
Upvotes: 3
Reputation: 51
I have same problem and fixed with this way:
You should install Java from Official Apple page.
http://support.apple.com/kb/DL1572
Upvotes: 1
Reputation: 1747
Just install this guy here
http://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US
and you should be good.
Upvotes: 173
Reputation: 165
Change this key in the 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.
Thanks!
Upvotes: 14
Reputation: 1139
I am using Mac OS X 10.10 also. And to fix this problem.
Search and replace:
<key> JVM version</key>
<string>1.6*</string>
replaced by:
<key> JVM version</key>
<string>1.6+</string>
That's it!
Upvotes: 9
Reputation: 8699
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.
The above works but is not recommended see RC3 Release 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).
see Android Studio failed to load JVM on Mac OSX (Mavericks)
Upvotes: 1