https://kotlinlang.org logo
#gradle
Title
# gradle
m

Miguel Oliveira

11/13/2023, 2:04 PM
Hi there! I'm developing a library and recently I've upgraded: Kotlin from 1.6.10 to
1.9.20
, AGP from 7.2.1 to
7.4.2
and Gradle from 7.6.1 to
8.4
. After publishing the library version with the updates, a client reported that he can no longer build using the library due to:
Copy code
e: C:/.../.gradle/caches/transforms-3/c84840751d0bf885b57987b97ba24946/transformed/jetified-kotlin-stdlib-1.9.20.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
even after deleting all caches. I have multiple android-only and multiplatform modules that are published, none has explicit declaration of kotlin-stdlib and I'm declaring: Android-only modules `build.gradle`:
Copy code
android {
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        languageVersion = '1.7'
        apiVersion = '1.7'
        jvmTarget = "1.8"
    }
}
Multiplaform modules `build.gradle.kts`:
Copy code
kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                languageVersion = "1.7"
                apiVersion = "1.7"
                jvmTarget = "1.8"
            }
        }
    }

    sourceSets {
        all {
            languageSettings {
                languageVersion = "1.7"
                apiVersion = "1.7"
            }
        }
    }
}
Does any one know what could be causing this? And am I missing something to keep the library compatible with Kotlin 1.7?
t

tapchicoma

11/13/2023, 2:46 PM
Looks like your project depends by default on
kotlin-stdlib:1.9.20
which is not compatible with Kotlin compiler 1.7. I would advice you to configure
kotlin.coreLibrariesVersion = "1.7.0"
👍 2
m

mbonnin

11/13/2023, 2:49 PM
@tapchicoma is that enough? Shouldn't there be
languageVersion = "1.7"
/`apiVersion = "1.7"` as well?
oh never mind, it's there already 🤦‍♂️
🙂 1
t

tapchicoma

11/13/2023, 2:52 PM
and related feature request
🙏 2
m

Miguel Oliveira

11/13/2023, 2:58 PM
😮 I wasn't aware of that
kotlin.coreLibrariesVersion = "1.7.0"
property, and in fact I thought that declaring the languangeVersion/apiVersion would be enough. I'm going to try it, thank you!
@tapchicoma does this configuration have any impacts on transitive dependencies? For instance, if some transitive dependency brings
kotlin-stdlib:1.9.20
, in the end the issue will persist, right?
t

tapchicoma

11/13/2023, 6:58 PM
hm, yes - it may happen
you could inspect Gradle build scan for transitive dependencies versions
👌 1
30 Views