I installed both Android Studio and the lates version of Oracles Java JDK 8.

When I type: java -version, it seems like I have installed java correctly:

java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

but when I try to run my App in Android Studio via my real device (LG Nexus 5X), I receive the following error:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> compileSdkVersion 'android-24' requires JDK 1.8 or later to compile.

When I check the PPA under Ubuntu Software Center, it seems like the Oracle Java Installer is activated (http://ppa.launchpad.net/webupd8team/java/ubuntu)

Unfortunatly, I have no idea how to solve this problem.

I am using a Acer Chromebook R11 with Croton and my Java version is installed under: /usr/lib/jvm/ and I also installed /usr/lib/jvm/default-java/

Thank you for your support.

I looked up the studio.sh file in order to figure out where Android Studio searches for the Java JDK.

# ---------------------------------------------------------------------
# Locate a JDK installation directory which will be used to run the IDE.
# Try (in order): STUDIO_JDK, ../jre, JDK_HOME, JAVA_HOME, "java" in PATH.
# ---------------------------------------------------------------------
if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then
elif [ -x "$IDE_HOME/jre/jre/bin/java" ] && "$IDE_HOME/jre/jre/bin/java" -version > /dev/null 2>&1 ; then
elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then
elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then

Both $JAVA_HOME and $STUDIO.JDK point to /usr/lib/jvm/java-8-oracle.

  • Can you check where does Android Studio looks for JDK? It's in File -> Project Structure -> JDK Location. Jul 24 '16 at 8:37
  • Thanks for your reply. I think Android Studio uses Path variables in order to find the java installation path. I edited my Question above with more information though, but the error still occurs and I cannot figure out why.
    – Andre
    Jul 24 '16 at 10:45

Finally it works. I was able to fix the problem by myself. I tried to fix the problem first over settings and than via Path-variables. Actually, I just needed to go to File->Project Structure... in Android Studio and edit the app properties as well as the JDK Location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.