I had this error after I updated Android Studio and opened an old project, full of incompatibility errors, I found this solution in a similar publication, just add the dependency and there was no more class duplication error.
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))