I can't compile a default new project for Android 2.1 because(?) the JDK used by Android Studio is JDK 1.7 but it should be JDK 1.6.

To change it I go to File -> Project Structure and try to find the JDK 1.6 location.

But when I select its directory and press OK I get the following error:

Please choose a valid JDK directory

Please choose a valid JDK directory

As you can see on the screenshoot I'm trying to set Java 6 OpenJDK 64-bits as the new JDK.

What can I do? Isn't Android Studio compatible with OpenJDK and should I use Oracle JDK instead?

  • Have you tried the bin folder? May 16, 2014 at 18:22
  • I tried with: ./bin | ./jre | ./jre/bin same message for all
    – Lucio
    May 16, 2014 at 20:17
  • 1
    For me I just had to use the folder above /jre in the directory structure, so my path is /usr/lib/jvm/java-8-oracle and not /usr/lib/jvm/java-8-oracle/jre. I assumed the path should end in /jre since the default path (the "embedded" JDK) does, but it turns out if you go look in the default folder, it's a folder called "jre" which contains another folder called "jre".
    – Jack M
    Feb 2, 2017 at 16:33

8 Answers 8


I'm using OpenJDK 7 with Android Studio and it works just fine. (I don't even have Oracle JDK installed at the moment.)

On that screen that you are showing (Project Structure-->SKD Location) I have the following path for the JDK location: /usr/lib/jvm/java-1.7.0-openjdk-amd64.


By inspecting studio.sh, you can also set one of STUDIO_JDK, JDK_HOME or JAVA_HOME environment variables to point to the JDK location.

studio.sh checks the STUDIO_JDK, JDK_HOME, and JAVA_HOME environment variables in order:

if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then
elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then

So you can just set them as appropriate and then Studio will pick it up.

  • This works for windows too. useful if you have a JDK with DCEVM as default in JAVA_HOME which does not work with android studio. Aug 10, 2016 at 19:41

It seems that Android Studio does not recognize OpenJDK, so I need to install the OracleJDK.

Then I choose the path to Oracle JDK and it worked!

  • i installed it but im unable to set its path variable. can you please tell me how can i do that? Mar 7, 2015 at 11:54
  • 1
    Yes, first make sure that java -version output correctly your Java version. Then, on the AS window choose /usr/lib/jvm/jdk1.8.0/. That was enough for me at that moment :-)
    – Lucio
    Mar 7, 2015 at 16:58
  • This should be done only after good consideration: this has massive legal implications, since Oracle changed their licensing terms in quite surprising ways. Typically you do not want to use Oracle java any longer in a comercial environment.
    – arkascha
    Oct 22, 2021 at 7:31

This worked for me:

  1. Find out the java directory:

    $ echo $JAVA_HOME
  2. Open Android Studio and then File-> Project Structure.

  3. Under SDK Location I past the java directory from above
  4. Wait a couple of seconds and I got "0 errores 0 advertencias"

It worked! :)


Steps I followed:

  1. Opened terminal and enter echo $JAVA_HOME

  2. Copied the path displayed in terminal - Ctrl+Shift+C copy in Ubuntu terminal

  3. In Android studio - Project Structure - Pasted the copied path

  4. Waited for the software to recognize and update the settings

  5. This solved the problem of Invalid Jdk settings


I fixed this problem. I use AS 2.1 and JDK1.7 while it required me to update JDK1.8 for some functions. I download the java setup file. Maybe I only installed jre but not jdk. so AS always warn me that "Please choose a valid JDK directory". So I guess the asker's problem same as me that you should install a JDK but not jre.


If you have a ./bin folder with a JDK and Android Studio, you can set the STUDIO_JDK variable before running studio.sh in a terminal:

STUDIO_JDK=./bin/jdk/ ./bin/android-studio/bin/studio.sh

I think that you might have installed the jdk somewhere else for e.g. /usr/local/java. In my case also I saw the same folder name in the directory shown in your screenshot.

So just check if the jdk is present somewhere else.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .