https://kotlinlang.org logo
Title
s

subham

06/22/2022, 1:41 PM
I am facing this problem after upgrading to version 3.3.2 /Users/subhamtyagi/.gradle/caches/modules-2/files-2.1/com.apollographql.apollo3/apollo-gradle-plugin/3.3.2/fcf5eff2ad1c8e0cd36be9e5457cf0257b4c3b01/apollo-gradle-plugin-3.3.2.jar!/META-INF/kotlinpoet.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1. Koltin -1.6.21 Ktor - 2.0.2 Coroutine - 1.6.3
👀 1
m

mbonnin

06/22/2022, 1:52 PM
Damn... Looks like you need to upgrade Gradle to 7.5-rc2...
Gradle still ships with Kotlin 1.5 by default that cannot read the 1.7 metadata from the latest version of KotlinPoet...
Does the error message say anything about potentially disabling this error? It might actually be a false positive
I can't reproduce in a simple project though 🤔 so there's more to it. Can you share how you're applying the plugin? (buildSrc, classpath, plugins {} block, something else?)
s

subham

06/22/2022, 2:17 PM
plugins {
    `kotlin-dsl`
}

initDeps(project)

repositories {
    mavenLocal()
    google()
    mavenCentral()
    maven("<https://plugins.gradle.org/m2/>")
    maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
}

dependencies {
    implementation(Deps.JetBrains.Kotlin.gradlePlugin)
    implementation(Deps.Android.Tools.Build.gradlePlugin)
    implementation(Deps.Squareup.SQLDelight.gradlePlugin)
    implementation(Deps.Apollo.gradlePlugin)
    implementation(kotlin("serialization", version = Deps.JetBrains.Kotlin.VERSION))
}

kotlin {
    // Add Deps to compilation, so it will become available in main project
    sourceSets.getByName("main").kotlin.srcDir("buildSrc/src/main/kotlin")
}
:thank-you: 1
I will try upgrading Gradle version if that fixes the issue
m

mbonnin

06/22/2022, 3:26 PM
Another workaround you can do is:
tasks.withType(KotlinCompile::class.java) {
    kotlinOptions {
        freeCompilerArgs = freeCompilerArgs + "-Xskip-metadata-version-check"
    }
}
s

subham

06/22/2022, 3:52 PM
It worked after upgrading to 7.5-rc2.
🎉 1
I will try above approach as well