'How should I debug JAR file version clashes in classpath?

I have a question regarding this error I picked up creating a new Compose project. First I created an Empty Compose Activity, then added the following dependencies for Room (as per developer.android guide):

implementation("androidx.room:room-runtime:2.4.1")
annotationProcessor("androidx.room:room-compiler:2.4.1")
kapt("androidx.room:room-compiler:2.4.1")
implementation("androidx.room:room-ktx:2.4.1")

When I ran the project I got the following build error:

> Task :app:compileDebugKotlin
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    C:/Users/wavec/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.31/ff5d99aecd328872494e8921b72bf6e3af97af3e/kotlin-stdlib-jdk8-1.5.31.jar (version 1.5)
    C:/Users/wavec/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.31/77e0f2568912e45d26c31fd417a332458508acdf/kotlin-stdlib-jdk7-1.5.31.jar (version 1.5)
    C:/Users/wavec/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.6.10/b8af3fe6f1ca88526914929add63cf5e7c5049af/kotlin-stdlib-1.6.10.jar (version 1.6)
    C:/Users/wavec/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.6.10/c118700e3a33c8a0d9adc920e9dec0831171925/kotlin-stdlib-common-1.6.10.jar (version 1.6)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

After some painful trial and error I figured out that if I change the version of "androidx.room:room-ktx:2.4.1" to 2.3.1 then it builds and runs without the error. What is a good way to debug this? I read similar past posts, but there were mixed answers and some of the IDE tools have changed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source