Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio and JRE on OS X

Installing AndroidStudio 2.0 on OS X El Capitan: if I install JRE 7 from http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html, I will not receive Public Updates; if I install JRE 8, Android Studio complains that it cannot use secure connection to receive upgrades:

Android Studio and Java screenshot

Is there a way to convince AS that JRE 8 is not JRE 6? If impossible, which compromise is preferable: downgrade to JRE 7 and establish secure connection for Android Studio upgrades, or keep the latest JRE and wait for Android Studio fix?

like image 962
Alex Cohn Avatar asked Apr 10 '16 14:04

Alex Cohn


People also ask

Does JRE work on Mac?

Determining the JRE Version Installed on macOS Only one JRE can be installed on the system at any time. Installing a JRE removes the previously installed JRE. The JRE version installed on the system can be determined in one of two ways: From System Preferences, and then the Other section, click the Java icon.

Do I need JRE for Android Studio?

Android Studio is a customized version of JetBrains' IntelliJ IDE, which is, in turn, a Java application. Therefore, as we established, to launch IntelliJ (and, consequently, Android Studio) on your computer, you need to have JRE installed.

Can Android Studio be installed on Mac?

To install Android Studio on your Mac, proceed as follows: Launch the Android Studio DMG file. Drag and drop Android Studio into the Applications folder, then launch Android Studio. Select whether you want to import previous Android Studio settings, then click OK.

Is Java required for Android Studio in Mac?

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.


2 Answers

From the documentation, by default Android Studio is launched from java 6: http://tools.android.com/tech-docs/configuration/osx-jdk

As it is mentioned you can export an env variable to indicate Android Studio what jdk to use :

export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk<version>.jdk

In order to keep this env variable accessible from the GUI, you can add the following line to your ~/.profile file :

launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk<version>.jdk

Hope it helps.

like image 146
akofman Avatar answered Nov 11 '22 12:11

akofman


Another solution for OSX: go to the Applications folder, right click on Android Studio, choose "Show Package Contents".

Open the Info.plist file. Locate the JVMVersion key, and set the string value you need.

In my case, I needed to be 1.7 and up to be able to run the RoboVM plugin, and the value was 1.6*,1.7+, so I left it only on 1.7+.

Restart Android Studio and it should be using the version of the JVM you need.

This works if you have root access on your Mac.

refers to Android Studio IDE with private jre/jdk? OSX


In Android Studio 2.1.2 and below,the default settings is '1.6*,1.7+'.

In the latest version of Android Studio(2.2 Preview 7),the default settings is '1.8*,1.8+'.

like image 21
Rachel Waffle Avatar answered Nov 11 '22 10:11

Rachel Waffle