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
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.
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.
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).
As per the docs, JDK 17 isn't supported yet in Android Studio.
In Android Studio open:File
> Project Structure
> see if JDK location points to your JDK 1.8 directory.
Note: you can use compileSdkVersion 24
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With