How to solve errors Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt…
I recently started upgrading my android studio and i found several errors. One that came most within my projects is Duplicate class kotlin.collections.jdk8.Collections JDK8Kt…
Let solve it in this troubleshoot.
Solve Duplicate class kotlin.collections.jdk8.Collections JDK8Kt… errors after upgrading android studio
After upgrading android studio to flamingo at the time i am writing this post, i still meet errors. Just duplicate class errors !! Other bugs seems to be already fixed.
To fix it, go to your build.gradle file ( the first one with your project name ) and replace the code below :
plugins { …. id 'org.jetbrains.kotlin.android' version '1.6.21' apply false }
I change the version 1.6.21 to the latest possible version like 1.8.22 in my case instead of using the recommanded version mentionned in error console.
Why ? i will explain it in the next section !!
Your code now may look like this one
plugins { …. id 'org.jetbrains.kotlin.android' version '1.8.22' apply false }
If you run your project after applying replacing this piece of code, you may find another error. It may be something like that :
This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.8.22
If it is, don’t worry there are solution of it. If you dont have any erros, just thanks GOD and code happily.
Why didn’t i choose the recommanded version of kotlin plugin ?
If you are using jetpack compose, and use the latest version of android kotlin you have to find and use a compatible version of Compose Compiler that work with your updated plugins.
You probably may find an errors like this
This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.8.22
That was mine for one of my project.
To solve it, i used a specific version of Compose Compiler that match the current version: 1.8.22 .