Warning: Kotlin JAR files must have the same version to run on the classpath

I get the following warning, but I'm not sure where v1.0.6 is located.

Is it possible that this error comes from the Kotlin library, one way or another, including the old version of Kotlin?

Any ideas on how to fix this, or at least how can I follow the suggestion to make kotlin-reflect explicit (1.1)?

enter image description here

+50
kotlin
source share
4 answers

It seems your project is set up in such a way that you are dependent on kotlin-stdlib 1.1 and kotlin-reflect 1.0. The most likely case is that you already have an explicit dependency on kotlin-stdlib 1.1, but have no dependency on kotlin-reflect , and some other library (which you depend on) depends on kotlin-reflect 1.0.

If this is true, the solution should provide explicit dependency on kotlin-reflect 1.1.

In Maven, add this to pom.xml :

  <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-reflect</artifactId> <version>1.1.0</version> </dependency> </dependencies> 

In Gradle, add this to build.gradle :

 dependencies { compile "org.jetbrains.kotlin:kotlin-reflect:1.1.0" } 

See information on this and related warnings in white papers .

+67
source share

I fixed the warning by rewriting the kotlin version used in my application

 configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'org.jetbrains.kotlin' && requested.name == 'kotlin-reflect') { details.useVersion kotlin_version } } } 

e.g. kotlin_version = 1.3.0

+15
source share

I ran into the same problem, but it was due to a wrong dagger injection

0
source share

this happens when you use a dagger in a kotlin (android) project and you have kotlin version 1.7, i.e.

 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 

all you have to do is add the dependency below to your applicationโ€™s fitness level

  implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50" 
0
source share

All Articles