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.
![](https://readforlearn.com/wp-content/uploads/2021/12/T9k02-1024x707.png)
See https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jvm_settings