0

When I go to build - Generate Signed APK I get this error:

Error:Execution failed for task ':app:compileReleaseJavaWithJavac'.

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

What is the solution?

Community
  • 1
  • 1
Adam Lia
  • 9
  • 1

4 Answers4

2

This could be a lot of things. For starters, try File -> Invalidate Cache / restart. Doing this is always my first step. If that doesn't work, go into Project Structure and make sure your Project SDK is correct and that you have it properly linked to your JDK. Go into Facets and make sure the Compile Sdk Version is also correct. Also make sure your Java Compiler is correct. you can find that under Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler.

1

I'm guessing you're using Android Studio as an IDE, correct? In that case, make sure you're using the latest JDK 1.8 (check your environment settings).

Cort-X7
  • 94
  • 5
1

You need to use the Java8 JDK if you want to use the Android API 24 as your compile SDK. In order to do so (assuming you are using Android Studio) go to "File/Project Structure" and then to the "SDK Location" option. There in the "JDK location" field put the path of your Java8 JDK. When you are ready press "OK" and rebuild your project.

josemgu91
  • 719
  • 4
  • 8
0

You need to update your JDK and apply it to Android Studio/IntelliJ.

As the error message says, you need newer version of the JDK (at least Java 8) to compile the APK with that or a higher compileSdkVersion

Zoe
  • 27,060
  • 21
  • 118
  • 148