Rafael Costa
05/31/2025, 7:43 AMmbonnin
05/31/2025, 7:46 AMlamguageVersion
and coreLibrariesVersion
.mbonnin
05/31/2025, 7:47 AMRafael Costa
05/31/2025, 7:48 AMmbonnin
05/31/2025, 7:48 AMmbonnin
05/31/2025, 7:49 AMRafael Costa
05/31/2025, 7:49 AMmbonnin
05/31/2025, 7:50 AMcoreLibrariesVersion
Rafael Costa
05/31/2025, 7:50 AMmbonnin
05/31/2025, 7:50 AMapiVersion
there are youtracks about thismbonnin
05/31/2025, 7:50 AMRafael Costa
05/31/2025, 7:50 AMmbonnin
05/31/2025, 7:51 AMRafael Costa
05/31/2025, 7:51 AMRafael Costa
05/31/2025, 7:55 AMmbonnin
05/31/2025, 8:16 AMmbonnin
05/31/2025, 8:17 AMRafael Costa
05/31/2025, 8:18 AMapi(libs.ktor)
is it an issue in this case?mbonnin
05/31/2025, 8:18 AMRafael Costa
05/31/2025, 8:18 AMmbonnin
05/31/2025, 8:18 AMmbonnin
05/31/2025, 8:20 AM./gradlew dependencies
. IIIRC, the configuration to check is the apiElements
oneRafael Costa
05/31/2025, 8:21 AMmbonnin
05/31/2025, 8:22 AMRafael Costa
05/31/2025, 9:00 AMe: file:///Users/rafael.costa/personal/ElectricEelSdkTests/app/src/main/java/com/ramcosta/electriceelsdktests/MainActivity.kt:14:15 Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
The class is loaded from /Users/rafael.costa/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.1.20/aa8ca79cd50578314f6d1180c47cbe14c0fee567/kotlin-stdlib-2.1.20.jar!/kotlin/Unit.class
I see lots of references to stdlib 2.1.20 when I run ./gradlew :main-module:dependencies
but it's kinda hard to interpret this output ๐
If I search for "apiElements" they all seem "empty".
running now with --scan
, see if I can spot anythingmbonnin
05/31/2025, 9:04 AMcompileClasspath
is the onembonnin
05/31/2025, 9:05 AMkotlin-stdlib:2.1.0
Rafael Costa
05/31/2025, 9:15 AMcoreLibrariesVersion
Rafael Costa
05/31/2025, 9:16 AMRafael Costa
05/31/2025, 9:17 AMextensions.configure<KotlinMultiplatformExtension> {
coreLibrariesVersion = "1.8.0"
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
}
}
mbonnin
05/31/2025, 9:18 AMmbonnin
05/31/2025, 9:19 AMkotlin-stdlib
to your dependencies...mbonnin
05/31/2025, 9:20 AMkotlin.stdlib.default.dependency=false
mbonnin
05/31/2025, 9:20 AMmbonnin
05/31/2025, 9:21 AMRafael Costa
05/31/2025, 11:15 AMcompileClasspath
which still depend on stdlib. My understanding was that only things that are part of the module public API would be there right? ๐ค
Also, I've tried forcing the stdlib dependency with something like:
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute(module("org.jetbrains.kotlin:kotlin-stdlib"))
.using(module("org.jetbrains.kotlin:kotlin-stdlib:1.8.0"))
.because("whatever")
}
}
}
but when compiling with that I get an exception somthing like:
java.lang.AssertionError: Type should be an array, but was KClass<out Annotation>: [NormalClass(value=kotlinx/coroutines/InternalForInheritanceCoroutinesApi)]
It looked promising since on compileClasspath
I don't see references to 2.1.20 stdlib.mbonnin
05/31/2025, 11:20 AMmbonnin
05/31/2025, 11:21 AMmbonnin
05/31/2025, 11:22 AM./gradlew outgoingVariants
say?mbonnin
05/31/2025, 11:23 AMRafael Costa
05/31/2025, 11:23 AMRafael Costa
05/31/2025, 11:27 AMRafael Costa
05/31/2025, 11:28 AMmbonnin
05/31/2025, 11:58 AMconfigurations.resolvable("exportedCompileClasspath") {
extendsFrom(configurations.apiElements.get())
}
And then
./gradlew :modul:dependencies --configuration exportedCompileClasspath
mbonnin
05/31/2025, 11:58 AMapiElements
naming, probably use jvmApiElements
mbonnin
05/31/2025, 11:59 AM./gradlew publishToMavenLocal
and then look inside the .module
file if you have publishing configuredmbonnin
05/31/2025, 11:59 AMRafael Costa
05/31/2025, 12:32 PMmbonnin
05/31/2025, 1:11 PMcompatPatrouille
to check for that:
โข https://github.com/GradleUp/compat-patrouille/pull/2Rafael Costa
05/31/2025, 1:51 PMgradle :app:dependencies
(after not seeing any mention to stdlib 2.1 in .module files that I'm expecting to be used directly).
Is it possible that runtimeClasspath actually does matter for what stdlib gets picked up in the end? Meaning that even if all my modules that use 2.1 are not part of my API 2.1 could still be required?
this image seems to suggest that (I just expanded the debugCompileClasspath
)Rafael Costa
05/31/2025, 1:52 PM->
arrows mean
<version specified> -> <version after resolution>
right?Rafael Costa
05/31/2025, 2:25 PMmbonnin
05/31/2025, 2:35 PMmbonnin
05/31/2025, 2:36 PMmbonnin
05/31/2025, 2:37 PMRafael Costa
05/31/2025, 2:37 PMRafael Costa
05/31/2025, 2:37 PMmbonnin
05/31/2025, 2:37 PMRafael Costa
05/31/2025, 2:37 PMmbonnin
05/31/2025, 2:38 PMRafael Costa
05/31/2025, 3:02 PMgradlew :app:dependencies --configuration debugCompileClasspath
Gives me a bunch of this:
+--- org.jetbrains.kotlin:kotlin-stdlib:1.8.22 -> 2.1.20 (*)
OR
\--- org.jetbrains.kotlin:kotlin-stdlib-common:2.1.20 (c)
OR a couple of (without a left side of the arrow version)
+--- org.jetbrains.kotlin:kotlin-stdlib -> 2.1.20 (*)
and a these two in the end as top level:
+--- org.jetbrains.kotlin:kotlin-stdlib:{strictly 2.1.20} -> 2.1.20 (c)
+--- org.jetbrains.kotlin:kotlin-stdlib-common:{strictly 2.1.20} -> 2.1.20 (c)
mbonnin
05/31/2025, 3:10 PMRafael Costa
05/31/2025, 3:19 PMmbonnin
05/31/2025, 3:20 PMmbonnin
05/31/2025, 3:21 PMlib
uses KGP 2.1 and has ktor as an implementation
dependency
โข app
uses KGP 1.8 and has lib as a dependencymbonnin
05/31/2025, 3:21 PMapi
dependency, then the build fails with
e: file:///Users/martinbonnin/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-serialization-core-jvm/1.8.1/510cb839cce9a3e708052d480a6fbf4a7274dfcd/kotlinx-serialization-core-jvm-1.8.1.jar!/META-INF/kotlinx-serialization-core.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
mbonnin
05/31/2025, 3:22 PMimplementation
, it is fineRafael Costa
05/31/2025, 3:22 PMRafael Costa
05/31/2025, 3:22 PMRafael Costa
05/31/2025, 3:22 PMmbonnin
05/31/2025, 3:22 PMdebugCompileClasspathSo this is an Android app, maybe something with AGP?
mbonnin
05/31/2025, 3:23 PMafterEvaluate {
afterEvaluate {
println(kotlin.coreLibrariesVersion)
}
}
Make sure no one touches that?Rafael Costa
05/31/2025, 3:23 PMandroidx.core:core-ktx
seems to have been forced to 1.13.1
which uses stdlib 2.1Rafael Costa
05/31/2025, 3:24 PMmbonnin
05/31/2025, 3:24 PMandroidx.core:core-ktx
an api
dependency?Rafael Costa
05/31/2025, 3:26 PMRafael Costa
05/31/2025, 3:26 PMMaybe try
```afterEvaluate {
afterEvaluate {
println(kotlin.coreLibrariesVersion)
}
}```2.1.20 ๐ฎ
Rafael Costa
05/31/2025, 3:29 PMRafael Costa
05/31/2025, 3:58 PMresolutionStrategy {
force 'org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.9.0'
force 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
}
AND
implementation('com.teya.pos:unified-sdk-core:0.0.1-internal37') {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
}
(yeah using groovy in this "old versions" project ๐)Rafael Costa
05/31/2025, 3:59 PMRafael Costa
05/31/2025, 4:03 PMexplicitApi()
mode... will dive into it.. even though it seems like it wouldn't be enough to fix it? ๐คทmbonnin
05/31/2025, 4:07 PMRafael Costa
05/31/2025, 4:09 PMRafael Costa
05/31/2025, 4:12 PMRafael Costa
05/31/2025, 4:18 PMRafael Costa
05/31/2025, 4:22 PMmbonnin
05/31/2025, 4:33 PMmbonnin
05/31/2025, 4:35 PMmbonnin
05/31/2025, 4:35 PMmbonnin
05/31/2025, 4:36 PMmbonnin
05/31/2025, 4:38 PMRafael Costa
05/31/2025, 4:43 PMRafael Costa
05/31/2025, 4:43 PMRafael Costa
05/31/2025, 4:44 PMRafael Costa
05/31/2025, 7:08 PMLkotlin/jvm/functions/Function1
(not sure if it could cause stdlib? but would be weird)
โข Some Composables which I marked as internal, but still seem like they leave some residue - also very weird, but not sure if could be the cause ๐ค , Like:
public final class com/teya/unifiedepossdk/internal/poslink/ui/stores/ComposableSingletons$NoStoresScreenKt {
public static final field INSTANCE Lcom/teya/unifiedepossdk/internal/poslink/ui/stores/ComposableSingletons$NoStoresScreenKt;
public fun <init> ()V
public final fun getLambda$1016637691$core ()Lkotlin/jvm/functions/Function2;
}
All this file has f.ex is a single internal @Composable function ๐คทRafael Costa
05/31/2025, 7:12 PMRafael Costa
06/02/2025, 12:11 AMlib
module as implementation
version 1.10.2.
โข If I check dependencies --configuration debugCompileClasspath
from app project importing lib
it is almost empty within the lib
tree - no mention on coroutines.
โข If I do gradle -q app:dependencyInsight --dependency org.jetbrains.kotlinx:kotlinx-coroutines-core --configuration debugCompileClasspath
I see this reason:
Selection reasons:
- By constraint: debugRuntimeClasspath uses version 1.10.2
- By ancestorMy theory: โข If the user of my lib also depends on the same library (in this case coroutines), then that library is put on
compileClasspath
โข Then gradle tries to use a consistent version between runtime and compile classpaths, so it ends up still choosing the newest one (1.10.2 in this case).
โข If the user would not depend on coroutines, then like you suggested at compile time the version I use does not matter, coroutines would not even be in the conversation.Rafael Costa
06/02/2025, 12:15 AMmbonnin
06/02/2025, 7:56 AMmbonnin
06/02/2025, 7:56 AMmbonnin
06/02/2025, 8:00 AMmbonnin
06/02/2025, 8:07 AMorg.jetbrains.kotlinx:kotlinx-coroutines-bom:{strictly 1.10.2} -> 1.10.2
Who's adding the coroutines BOM ๐ค ?Rafael Costa
06/02/2025, 8:13 AMRafael Costa
06/02/2025, 8:14 AMRafael Costa
06/02/2025, 8:14 AMRafael Costa
06/02/2025, 8:14 AMRafael Costa
06/02/2025, 8:17 AMmbonnin
06/02/2025, 8:23 AMmbonnin
06/02/2025, 8:28 AMmbonnin
06/02/2025, 8:28 AM// make compileClasspath match runtimeClasspath
compileClasspath.shouldResolveConsistentlyWith(runtimeClasspath);
mbonnin
06/02/2025, 8:28 AMmbonnin
06/02/2025, 8:29 AMandroid.experimental.dependency.excludeLibraryComponentsFromConstraints
to disable thisRafael Costa
06/02/2025, 8:30 AMmbonnin
06/02/2025, 8:30 AMmbonnin
06/02/2025, 8:30 AMmbonnin
06/02/2025, 8:30 AMRafael Costa
06/02/2025, 8:30 AMmbonnin
06/02/2025, 8:30 AMmbonnin
06/02/2025, 8:31 AMmbonnin
06/02/2025, 8:44 AMmbonnin
06/02/2025, 8:52 AMRafael Costa
06/02/2025, 8:58 AMRafael Costa
06/02/2025, 8:58 AMAlright, this worked for me: https://github.com/martinbonnin/reproducers/commit/57342e3601887165636ebc6111a41ae759dea748Will try this one ๐
mbonnin
06/02/2025, 9:06 AMRafael Costa
06/02/2025, 9:07 AMRafael Costa
06/02/2025, 9:07 AMRafael Costa
06/02/2025, 9:24 AM* What went wrong:
Execution failed for task ':app:checkDebugClasspath'.
> Cannot fingerprint input property 'compileVersionMap': value '{Info(group=org.jetbrains.kotlin, module=kotlin-stdlib-jdk8)=1.8.0, ........}' cannot be serialized.
I added it only in the consuming project. In your reproducer it is applied also to the lib I'm assuming? ๐ค
Not sure if that matters.Rafael Costa
06/02/2025, 9:25 AMandroid.enableCompileRuntimeClasspathAlignment=false
as seen on that google issue, but it apparently has no effect whatsoever here..mbonnin
06/02/2025, 9:27 AMcheckDebugClasspathSounds like you're using an older AGP?
mbonnin
06/02/2025, 9:27 AMRafael Costa
06/02/2025, 9:28 AMRafael Costa
06/02/2025, 9:28 AMmbonnin
06/02/2025, 9:28 AMRafael Costa
06/02/2025, 9:28 AMmbonnin
06/02/2025, 9:28 AMcheckDebugClasspath
task?Rafael Costa
06/02/2025, 9:29 AMmbonnin
06/02/2025, 9:29 AMRafael Costa
06/02/2025, 9:29 AMmbonnin
06/02/2025, 9:29 AMmbonnin
06/02/2025, 9:30 AMRafael Costa
06/02/2025, 9:30 AMmbonnin
06/02/2025, 9:30 AMmbonnin
06/02/2025, 9:31 AMmbonnin
06/02/2025, 9:31 AMRafael Costa
06/02/2025, 9:31 AMmbonnin
06/02/2025, 9:31 AMRafael Costa
06/02/2025, 9:32 AMRafael Costa
06/02/2025, 9:33 AMmbonnin
06/02/2025, 9:33 AMRafael Costa
06/02/2025, 9:33 AMRafael Costa
06/02/2025, 9:34 AMRafael Costa
06/02/2025, 9:34 AMRafael Costa
06/02/2025, 9:34 AMRafael Costa
06/02/2025, 9:35 AMmbonnin
06/02/2025, 9:35 AMmbonnin
06/02/2025, 9:36 AMmbonnin
06/02/2025, 9:36 AMRafael Costa
06/02/2025, 9:38 AMRafael Costa
06/02/2025, 9:39 AMmbonnin
06/02/2025, 9:39 AMRafael Costa
06/02/2025, 9:40 AMmbonnin
06/02/2025, 9:49 AM