I've got the same problem after updating my Android Studio to Ladybug (yes, bug)
Try to
- download and install JDK 17
- set JAVA_HOME environment variable
- set GRADLE JDK in Android Studio (Settings -> Build, Ex... -> Build Tools -> Gradle) to that location
- and try again.