Invalid Gradle JDK configuration found?

Solution 1:

I got this issue in Android studio 4.2 canary, and I had to delete those generated files:

.idea/gradle.xml
.idea/workspace.xml

then clicking try again to sync the project.

Solution 2:

Under Android Studio, select File > Project Structure > JDK location. Specify the JDK to the folder of your currently installed JDK. And specify the SDK location as well.