Reputation: 18521
I am using Gradle with intellij.
I refresh Gradle and then I rebuild my project.
I get the following
But I get the error that I should use -source7 or higher.
I also set the following at the settings
(With all of the inner modules are set to project sdk (1.8)) But I still can't rebuild or compile without this error. Any suggestions?
(obviously i deleted all my classes and jars and then Gradle refreshed and rebuild project)
Upvotes: 13
Views: 5743
Reputation: 116
I finally resolved this issue for myself. I'm on Windows and it turns out the order in which the JDKs are listed in the Windows environment variable matter, and overrode what IDEA had set.
Although my project has JDK11 listed everywhere, JDK17 was still being used. I was able to finally resolve this issue by moving their ordering to list JDK11 first.
before I swapped the env var order
Upvotes: 0
Reputation: 17344
I had this problem while trying to build Android Studio. I kept getting
Tools need to be compiled with Java 1.8, you are using Java 11
Everything in the Intellij global and "Project Structure" settings was set to Java 1.8 so I couldn't figure out what was going on. For whatever reason, what ended up working was going to Build, Execution, Deployment
> Build
> Gradle
and selecting the Amazon corretto version of Java 1.8 as installed by sdkman. This is baffling since I'd already tried selecting two other options for Gradle JVM that said 1.8 and both of those still resulted in the same error message as a result of Java 11 being used.
Upvotes: 0
Reputation: 189
Same issue; got it solved with the following:
Upvotes: 18
Reputation: 740
As of your second screen, make sure that all your modules are using the project default SDK, like in the screen below. The module setting may somehow be set to point older java version.
Upvotes: 0