Reputation: 32107
I’m trying to run Android Studio with JDK 13 just because I feel like it must run faster than the JDK 8 that comes embedded with it.
According to the documentation (which I found from umang shukla
's answer), we can force Android Studio to use something other than the embedded JDK by setting STUDIO_JDK
.
STUDIO_JDK
Sets the location of the JDK with which to run Studio. When you launch Android Studio, it checks the
STUDIO_JDK
,JDK_HOME
, andJAVA_HOME
environment variables in that order.
And I did that:
$ export STUDIO_JDK=`/usr/libexec/java_home -v 13`
$ echo $STUDIO_JDK
/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
$ open /Applications/Android Studio 3.5.app/
$ ps ax | grep Android
1198 ?? R 1:07.86 /Applications/Android Studio 3.5.app/Contents/MacOS/studio
1269 ?? S 0:00.02 /Applications/Android Studio 3.5.app/Contents/bin/fsnotifier
1300 s000 R+ 0:00.00 grep Android
$ ps eww 1198
PID TT STAT TIME COMMAND
1198 ?? S 1:46.13 /Applications/Android Studio 3.5.app/Contents/MacOS/studio ANDROID_HOME=/Users/hborders/Library/Android/sdk TERM_PROGRAM=Apple_Terminal JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home TMPDIR=/var/folders/r6/qtc_vgrx1xb2gqsg08y0tl000000gp/T/ __CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0 SHELL=/bin/bash _=/usr/bin/open HOME=/Users/hborders TERM_SESSION_ID=CA1F90D5-ABE9-427A-ACC5-EEE63AC66CAB SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.J9ll4GUN4M/Listeners Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.B3Rds8GPV9/Render TERM_PROGRAM_VERSION=421.2 SHLVL=1 PATH=/usr/local/bin:/Users/hborders/Library/Android/sdk/tools:/Users/hborders/Library/Android/sdk/platform-tools:/usr/local/opt/go/libexec/bin:/Users/hborders/go/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin DISPLAY=/private/tmp/com.apple.launchd.4O8kDH9XQS/org.macosforge.xquartz:0 TERM=xterm-256color LOGNAME=hborders XPC_SERVICE_NAME=com.google.android.studio.55476 LANG=en_US.UTF-8 GOROOT=/usr/local/opt/go/libexec GOPATH=/Users/hborders/go USER=hborders XPC_FLAGS=0x1 STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home PWD=/Users/hborders
However, when I look in Android Studio’s Collect Troubleshooting Information dialog, I get the following information:
Build version: Android Studio 3.5.1 Build #AI-191.8026.42.35.5900203 September 25, 2019
Java version: 1.8.0_202-release-1483-b49-5587405x86_64
Operating System: Mac OS X (10.14.6, x86_64)
JVM version: OpenJDK 64-Bit Server VM JetBrains s.r.o
I also tried launching Android Studio thusly:
$ /Applications/Android Studio 3.5.app/Contents/MacOS/studio
And I got the same result. I filed an Android Studio issue about this. Please star it.
Any ideas?
Upvotes: 3
Views: 5427
Reputation: 32107
TLDR
Don't try to do this. Android Studio 3.5.1 hangs when trying to change the boot jdk
. I filed this in the Android Studio issue tracker. Please star it.
Someone privately suggested:
cmd+shift+a
-> switch boot jdk
This definitely changed Android Studio's behavior. However, Android Studio 3.5.1
hung at the splash screen.
This happened when I tried to start it with either Oracle JDK 13
:
java version "13.0.1" 2019-10-15
Java(TM) SE Runtime Environment (build 13.0.1+9)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)
or Oracle JDK 11
:
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
To fix this problem, I found that Android Studio stores the boot jdk
preference in ~/Library/Preferences/<PRODUCT><VERSION>
on macOS (~/Library/Preferences/AndroidStudio3.5
in my case).
Then, I simply deleted the studio.jdk
file, and Android Studio started normally again.
Upvotes: 3
Reputation: 3065
Jetbrains has instructions for choosing the underlying runtime.
At a high level:
Install the Choose Runtime plugin
Then do "Find Action" in the IDE and select "Choose Runtime"
Upvotes: 0