gradle Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'

Are you using an IDE? Make sure that in your Gradle settings, Gradle is using the same java version as your project, this can be easily configured in Intellij https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jdk_existing_project


  • It turns out that gradle was after all the one to blame.
  • Probably similar to this post, I upgraded to gradle-6.7.
  • Then, calling gradle-6.7 --version, without any JAVA_HOME change whatsoever, I got:

------------------------------------------------------------
Gradle 6.7-rc-3
------------------------------------------------------------

Build time:   2020-09-30 19:16:51 UTC
Revision:     836e96a80625c9c48b612e662e3b13bd2e2f4c3b

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OS:           Linux 5.4.0-48-generic amd64

Which probably "proves" gradle is indeed the one to blame


Gradle uses the java distribution defined in your JAVA_HOME environment variable - it does not look at the java executable in your path. So make sure this variable points to a valid JDK 11 path. You can verify if it is set up correctly by running gradle --version, e.g.

$ echo %JAVA_HOME%
C:\Work\JDKs\jdk-11.0.8+10


$ gradle --version

------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------

Build time:   2020-08-10 22:06:19 UTC
Revision:     d119144684a0c301aea027b79857815659e431b9

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          11.0.8 (AdoptOpenJDK 11.0.8+10)
OS:           Windows 10 10.0 amd64

(Notice the JVM part above.)


I got this problem when trying to build using gradle through Intellij.

In my case I had two JDK's JDK1.8 and JDK 11 installed and configured in Intellij. For Gradle it was taking JDK1.8 as default JVM. I solved the issue using below steps :

  1. Open Intellij
  2. Go to Preferences
  3. Go to "Build, Execution, Deployment" -> "Build Tools" -> Gradle
  4. Search for "Gradle JVM". Change it to desired JVM
  5. Try to rebuild the app