# Pick the right JDK for Android Studio

DevFeed: [Pick the right JDK for Android Studio](<https://devfeed.tech/articles/pick-the-right-jdk-for-android-studio-25339.md>)

Original publisher: [Read original article](<https://kau.sh/blog/studio-jdk/>)

Author: Kaushik Gopal

Published: 2024-03-06T08:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Android](<https://devfeed.tech/topics/android.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [ide](<https://devfeed.tech/topics/ide.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [ide](<https://devfeed.tech/tags/ide.md>), [java](<https://devfeed.tech/tags/java.md>), [jdk](<https://devfeed.tech/tags/jdk.md>), [sdk](<https://devfeed.tech/tags/sdk.md>)

## AI overview

A guide for Android developers on configuring the JDK for Android Studio. It recommends using the JDK bundled with Android Studio, selecting it as the Gradle JDK, and keeping it aligned with JAVA_HOME to avoid conflicting Gradle daemons and IDE or build errors.

## Source excerpt

If Android developers don't setup the JDK correctly, you'll be greeted with nasty errors like this: Check your module classpath error Cannot access 'java.lang.constant.Constable' which is a supertype of 'java.lang.Class'. Check your module classpath for missing or conflicting dependencies Your app might compile fine but the IDE will keep surfacing pesky errors. This is because Android developers have a variety of ways to setup the JDK for your development environment. Too many. On episode #249 of Fragmented we discussed the numerous JDK options and what they're used for. Google now has an excellent developer doc for this.1 Courtesy: Android Developer docs If you don't have time to catch up on all the valuable content above, here's the takeaways: 1. Use the JDK that comes with Android Studio # JBR2 is battle tested with Android Studio and includes enhancements for running Android Studio well. To use it as your SDK, switch your Gradle JDK to JBR: how to set jbr as your gradle jdk Do a File > Invalidate Caches after this... mother of all fixes 2. Match yourJAVA_HOME with the Gradle JDK # The Gradle JDK from Step 1 is used to compile your app from Android Studio. If you use the command line to build your app on the other hand, the JDK from your $JAVA_HOME3 is used. If both of these don't match, you can have multiple gradle daemons running around. Make sure to match the two. # ~/.zshenv export JAVA_HOME=$HOME/Applications/Android\ Studio.app/Contents/jbr/Contents/Home If you're not sure where the jbr-jdk is located: This is the way. no seriously, it's really good. ↩︎ JetBrains Runtime ↩︎ ...if you haven't customized your environment too much. It's a little more involved. ↩︎