Gradle - Could not target platform: 'Java SE 8' using tool chain: 'JDK 7 (1.7)'
Finally I imported my Gradle project. These are the steps:
- I switched from local Gradle distrib to Intellij Idea Gradle Wrapper (gradle-2.14).
- I pointed system variable
JAVA_HOME
to JDK 8 (it was 7th previously) as I had figured out by experiments that Gradle Wrapper could process the project with JDK 8 only. - I deleted previously manually created file gradle.properties (with
org.gradle.java.home
variable) in windows user .gradle directory as, I guessed, it didn't bring any additional value to Gradle.
This is what worked for me (Intellij Idea 2018.1.2):
1) Navigate to: File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
2) Gradle JVM: change to version 1.8
3) Re-run the gradle task
For IntelliJ 2019:
Intellij IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM
Select correct version.
For IntelliJ 2019, JDK 13 and gRPC:
Intellij IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM
and Select correct version.
you might also have to adding below line in your build.gradle dependencies
compileOnly group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'