question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible versions of Kotlin metadata - 1.5.1 expected

See original GitHub issue

I’ve added the easylauncher dependency in version 5.1.1 and Gradle sync returns following error:

com.project.starter/easylauncher/5.1.1/aa3307d8bfca4f9f3cb222f52c82095333094081/easylauncher-5.1.1.jar!/META-INF/easylauncher.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.

I’m using the build-logic pattern for Gradle, and my convention plugin for easylauncher is pretty straightforward:

class EasylauncherConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) = with(target) {
        pluginManager.apply("com.starter.easylauncher")
    }
}

I’ve checked the dependency graph of my project with ./gradlew dependencies but none of the deps I have include Kotlin versions below 1.6.20. The complete list of other dependencies I’ve included:

[versions]
androidDesugarJdkLibs = "1.1.5"
androidGradlePlugin = "7.2.1"
androidxAppCompat = "1.4.2"
androidxCore = "1.8.0"
detekt = "1.20.0"
easylauncherGradlePlugin = "5.1.1"
junit4 = "4.13.2"
kotlin = "1.7.0"
kotlinterGradlePlugin = "3.10.0"
material3 = "1.6.1"

[libraries]
android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" }
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
detekt-gradlePlugin = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version.ref = "detekt" }
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }
easylauncher-gradlePlugin = { group = "com.project.starter", name = "easylauncher", version.ref = "easylauncherGradlePlugin" }
junit4 = { group = "junit", name = "junit", version.ref = "junit4" }
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinter-gradlePlugin = { group = "org.jmailen.gradle", name = "kotlinter-gradle", version.ref = "kotlinterGradlePlugin" }
material3 = { group = "com.google.android.material", name = "material", version.ref = "material3" }

I did some investigating but I failed to understand where the issue may come from. It is caused by adding the easylauncher plugin, because removing the plugin dependency fixes Gradle sync problems, but I’m not able to locate it’s source. Any advice on how to approach this?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ikurekcommented, Jun 22, 2022

I’m trying to implement the build-logic approach so I can easily share configurations between multiple app modules in a project. My goal is to create Convention Plugins for each commonly used dependency (ktlint, detekt, etc) so they can be easilly applied to modules app1, app2, etc.

For a start, here’s my structure of build-logic module - it’s almost the same as in the sample I provided:

build-logic
├── convention
│   ├── build.gradle.kts
│   └── src
│       └── main
│           └── kotlin
│               ├── AndroidApplicationConventionPlugin.kt
│               ├── DetektConventionPlugin.kt
│               ├── KtlintConventionPlugin.kt
│               └── com
│                   └── myapp
│                       ├── BuildFlavor.kt
│                       └── KotlinAndroid.kt
└── settings.gradle.kts

How do you apply the kotlin gradle plugin to build-logic project?

Here’s the entire build.gradle.kts file from build-logic/convention. I’ve removed references to easylauncher to make sure that this version works fine.

plugins {
    `kotlin-dsl`
}

group = "com.myapp.buildlogic"

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
    implementation(libs.android.gradlePlugin)
    implementation(libs.kotlin.gradlePlugin) <- kotlin gradle plugin
    implementation(libs.detekt.gradlePlugin)
    implementation(libs.kotlinter.gradlePlugin)
}

gradlePlugin {
    plugins {
        register("androidApplication") {
            id = "com.myapp.application"
            implementationClass = "AndroidApplicationConventionPlugin"
        }
        register("detekt") {
            id = "com.myapp.detekt"
            implementationClass = "DetektConventionPlugin"
        }
        register("ktlint") {
            id = "com.myapp.ktlint"
            implementationClass = "KtlintConventionPlugin"
        }
    }
}

also, in the root myapp directory, there’s a build.gradle.kts file defined like this:

buildscript {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }

    dependencies {
        classpath(libs.android.gradlePlugin)
        classpath(libs.kotlin.gradlePlugin) <- kotlin gradle plugin
    }
}

Can you cd into build-logic project and share the output of gradle dependencies?

I can, but the build-logic module doesn’t seem to report anything with dependencies command:

> Task :dependencies

------------------------------------------------------------
Root project 'build-logic'
------------------------------------------------------------

No configurations

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 848ms

But I’ve ran the same command in build-logic/convention and got this (posted as gist since it’s pretty long)

Sorry that I’m not able to explain that in-depth - I’m not a gradle pro and I’m trying to figure out what the problem may be myself 😓

0reactions
mateuszkwiecinskicommented, Jun 23, 2022

5.1.2 should be now available - I hope the workaround I pasted above will work for you 😃 If for some reason it does not - please let me know 👀

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Module was compiled with an incompatible version of Kotlin ...
"Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16" ; 1....
Read more >
Module was compiled with an incompatible version of Kotlin ...
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15. #2578.
Read more >
[Solved] Module was compiled with an ... - Flutter Campus
kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15. e:...
Read more >
Solutions to the problem "the binary version of its metadata is ...
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....
Read more >
[Solved] Module was compiled with an ... - YouTube
Module was compiled with an incompatible version of Kotlin. Solve Kotlin version error.Error: Kotlin : Module was compiled with an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found