TL;DR; You need to have the Java
version which is compatible with your Gradle
version, and configure Gradle to use exactly that version (not older Java, and not even newer version).
I fixed this problem by changing the Gradle JVM settings in IntelliJ settings:
-
In the Settings/Preferences dialog, go to Build, Execution, Deployment → Build Tools → Gradle.
-
Under the Gradle section, change the Gradle JVM option. Select a Gradle JVM which works for you.