For Mac-:
Increase Android Gradle version and AGP, then change the Android JDK version to latest from project structure , mention that version in Gradle
compileOptions {
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
}