First of all Unknown Kotlin JVM target: 21 itself says that current set target jvm is 21.
Reason: After updating android studio sometimes sets default jvm target automatically without informing / prompting and that causes the confusion.
Steps
Optionally gradle command can also be used ./gradlew clean build
Run sync project with gradle
Rebuild the project from Build -> Rebuild project
It starts working.