I've had the same issue when upgrading the java version in my app module, but forgot to update the kotlin jvmToolchain version. Don't be me. Make sure to check, that all specified java versions match.
android {
kotlin {
jvmToolchain(JAVA_VERSION as a number)
}
}