Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'android-24' requires JDK 1.8 or later to compile

I use Android Studio and recently got the error:

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

But I have JDK 1.8 installed already:

:\Users..>java -version
java version "1.8.0_91" Java(TM) SE Runtime
Environment (build 1.8.0_91-b15) Java HotSpot(TM) 64-Bit Server VM
(build 25.91-b15, mixed mode)

How to fix it? Thanks

like image 565
T D Nguyen Avatar asked Jun 21 '16 00:06

T D Nguyen


People also ask

What version of JDK is required for Android Studio?

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

Can I use JDK 11 for Android Studio?

Up to Android Studio 3.5 beta 2 one could use JDK11 for compiling project by configuring it in Project Structure -> SDK Location -> JDK Location. This way Android Studio is run under bundled JDK8 but Gradle is using selected JDK11. Starting from Android Studio 3.5 beta 3 this setup is no longer supported.

Is Java SDK required for Android Studio?

Since Android's source code is in Kotlin (or Java), you'll need to install the Java Development Kit (JDK) as well. You can download it here. This installation pack contains both Android Studio and the SDK (software development kit).

Can I use Java 17 for Android Studio?

As per the docs, JDK 17 isn't supported yet in Android Studio.


1 Answers

In Android Studio open:
File > Project Structure > see if JDK location points to your JDK 1.8 directory.

Note: you can use compileSdkVersion 24

like image 130
Juan Cruz Soler Avatar answered Oct 05 '22 05:10

Juan Cruz Soler