Check the java version you are using. The recommended one is Eclipse Adoptium\jdk-17.0.15.6-hotspot and don't forget to add it to your system environment variable and adapt each file in your code so that gradle uses this same version of jdk. I had this error because I am using a very recent version of jdk (23)