Issue
I decided to add a couple Kotlin files to an existing Java Android project in AS 3.0.
Once I added Kotlin files, I let the assistant add the appropriate lines to my build.gradle
files, in particular:
project build.gradle
buildscript {
ext.kotlin_version = '1.2.21'
//...
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
app build.gradle
// top of file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//....
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Unfortunately all builds now produce this warning:
Warning:Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/sddsfsd/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.21/88bfff5aa470143a83b0bc5ec00c0be8cabd7cad/kotlin-stdlib-jdk7-1.2.21.jar (version 1.2)
/Applications/Android Studio.app/Contents/gradle/m2repository/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.51/kotlin-stdlib-jre7-1.1.51.jar (version 1.1)
/Users/sddsfsd/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.2.21/d64187eb2d9d1521be3421aa8c6774a8625cdde8/kotlin-stdlib-1.2.21.jar (version 1.2)
Why does Android Studio have its own older version of Kotlin in the classpath? How do I remove it?
Solution
Why do I have different versions of Kotlin JARs in the classpath?
You have different versions because some of your dependencies depend on Kotlin 1.1 version.
Why does Android Studio have its own older version of Kotlin in the classpath? How do I remove it?
Updating your dependencies like I explained here in a related question about renamed stdlib-jre7 and already explained here for conflictive dependencies that have not been renamed.
Kotlin reference - binary compatibility warnings:
Runtime JAR files in the classpath should have the same version.
Some runtime JAR files in the classpath have an incompatible version.
Consider removing them from the classpath.
This means that you have a dependency on libraries of different versions, for example the 1.1 standard library and the 1.0 reflection library.
To prevent subtle errors at runtime, we recommend you to use the same version of all Kotlin libraries. In this case, consider adding an explicit dependency.
In your case, the indirect dependency was renamed and you need to update the library that uses it:
Find conflictive dependencies via command, or build tab since AS 3.1
./gradlew -q dependencies app:dependencies --configuration variantDebugCompileClasspath
In the related question, the warning was removed updating Realm version to 4.3.2.
Note: I checked my path and I also have outdated dependencies there but it's ok if you don't use it.
Answered By - albodelu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.