Run Android Studio with Java 8 - android-studio

Since a plugin for IntelliJ (Upsource) requires Java 8 I'd like to run my Android Studio with Java 8 on a Mac.
I could setup JAVA_HOME and start Android Studio from terminal but this is very inconvenient. I'd like to start Android Studio from the OSX UI.
I did not find a way how to specify the JAVA_HOME with Android Studio settings. Moreover this link (https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under) says nothing about Android Studio.
Does anyone know where to configure the Runtime-JDK/JRE for Android Studio 2.1 on OSX without setting any JAVA_HOME?

From http://tools.android.com/tech-docs/configuration
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk
You can also have a look here: http://tools.android.com/tech-docs/configuration/osx-jdk it explains how to set the jre for running android-studio and the jdk for your android project.
In short, you can in a terminal:
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
open /Applications/Android\ Studio.app
And it will launch android_studio with the jdk8
EDIT: from comment #Soccertrash
You can persist the STUDIO_JDK variable via launchctl:
launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk<version>

Related

Why is android studio not opening?

I try to open android studio but it says
Failed to open JVM DLL if you have JDK installed set JAVA_HOME variable....
I set the JAVA_HOME variable, downloaded new jdk
set it to that and redownloaded android studio but nothing is working.
It says to install Microsoft Visual C++ Redistributable
Installing it provides a "missing vcruntime140_1.dll file in bundled Java Runtime" to the Android Studio.
read - https://issuetracker.google.com/issues/247854802?pli=1
buddy hopes you are doing great this crash happens when an awful java path is changed or deleted.
This same error I already faced when the new update I downloaded to Android Studio Electric Eel | 2022.1.1
To solve this you need to change the path from the environment or you should delete the old java and download the new JDK and give the path.
You should follow this answer: https://stackoverflow.com/a/27113946/19674027 for better understanding
Happy Coding...

Save Gradle JDK in AndroidStudio BumbleBee between runs

In AndroidStudio BumbleBee, there does not appear to be a way to configure the Gradle JDK that persists between full builds of the target app. Our app requires JDK 8 and Gradle requires JDK 11...
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
We develop our Cordova webapp (JS/CSS) on Mac for desktop first and then port to mobile. We do full builds, not incrementals.
Changing org.gradle.java.home does not work and might be too late as the JDK is already launched to run Gradle and parse org.gradle.java.home.
Changing JAVA_HOME sets the JDK for both our app and Gradle... and all other projects that use Java.
Chaning the IDE settings can be done manually... each full Cordova 11 build and launch of AndroidStudio. Here is how we have to set the Gradle JDK in AndroidStudio preferences... every time we launch Android Studio. Looking for a way to set the Gradle JDK in the IDE that will be honored between runs...
The dropdown includes the embedded JDK 11 that comes with AndroidStudio. This needs to be selected for the Gradle JDK to successfully build our app. Here is the dropdown...
Tried starting AndroidStudio from the commandline, where env variables can be set just for the launched process...
$ JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home" open "/Applications/Android Studio.app"
If there are no options in BumbleBee, are there plans for such support in later releases of Android Studio.

Is JDK 8 really important for Android Studio?

I recently installed Android Studio 2.3.3 on my Mac, but I forgot to install JDK 8 before setting up Android Studio. I am already halfway through the development process of my App, so know I don't want to uninstall Android Studio, then install JDK 8 and again reinstall Android Studio, so should I uninstall Android Studio for JDK 8, is it really that important?
First thing, JDK is important in Android Studio to compile your .java files. As you said you are half way through your development process ,there is a JVM in your machine(not necessarily JDK-8).
Android by default installs a JVM in your computer.
Open a project in Android studio,
Goto File -> Project Structure -> SDK location
There you can see, default JDK location, if there is no such thing then,
1.install JDK-8, and Set the Environmental variables.
2.Set the jdk path in the JDK location in the android studio.

When I run the Android App in Android Studio, these errors occurs

When I run the Android App in Android Studio, these errors occurs (see the attachment). The emulator appears. But there I cannot see the application written by me. How to fix this? I haven't created any app using Android Studio before. I'm using it on Windows 8.
enter image description here
Try starting Android Studio as an Administrator
Depending on the target android version you want to compile with, you might want to lower your JDK to 1.7.
If you're already running JDK 1.7, try reinstalling JRE and JDK

JdK1.8.0_45 path issue Android Studio

I am getting this issue repeatedly "Installing Android Studio, does not point to a valid JVM installation error" while launching Android Studio.
I have installed Eclipse and Android studio Both on My System. Eclipse is working fine but Android Studio is not Working now. Means Before Installation of Eclipse it was working well.
I have Set the Path="C:\Program Files(x86)\Java\jdk1.8.0_45\bin".
And I have also installed jdk1.7.0 and jdk1.6.0_07 on my system.
![enter image description here][1]
Android Studio Works With JDK 7 ans JDK 8 both:
Need to set jdk path like this;
JAVA_HOME = "C:\Program Files(x86)\Java\jdk1.8.0_45"

Resources