i have been there days ago and tried mixing versions trying to figure out
maybe try to make AGP compatible with gradle version
see this Link
and this Compatibility Matrix for jvm and gradle
and maybe edit this line
kotlinOptions {
jvmTarget = "1.8"
}
to
kotlinOptions {
jvmTarget = "17"
}