Based on the answer of DeveloperOmar 100 I found the following solution:
-
switch your Java version to a compatible version, in my case to Java version 16.0.2
To switch it you have to set your PATH. (e.g for Mac, you can use the
java_home
command). -
check your Gradle version and update that one too, so it is compatible (see the Gradle wrapper docs) so in my case I had to change the
distributionUrl
property inandroid/gradle/wrapper/gradle-wrapper.properties
:distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip