You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[2.57] Module was compiled with an incompatible version of Kotlin #4848
When trying to update to the latest Dagger/Hilt version 2.57, I get the following errors in my project:
e: file:///Users/alexandereggers/.gradle/caches/modules-2/files-2.1/com.google.dagger/hilt-android-gradle-plugin/2.57/e77a7c859d29dee90dab5b36fa9b5ff6971d498a/hilt-android-gradle-plugin-2.57.jar!/META-INF/main.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0.
e: file:///Users/alexandereggers/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.2.0/fdfc65fbc42fda253a26f61dac3c0aca335fae96/kotlin-stdlib-2.2.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0.
e: file:///Users/alexandereggers/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.2.0/fdfc65fbc42fda253a26f61dac3c0aca335fae96/kotlin-stdlib-2.2.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0.
e: file:///Users/alexandereggers/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.2.0/fdfc65fbc42fda253a26f61dac3c0aca335fae96/kotlin-stdlib-2.2.0.jar!/META-INF/kotlin-stdlib.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0.
AGP: 8.11.1
Kotlin: 2.2.0
Gradle Wrapper: 8.14.3
Let me know if you need any additional details about my project setup. I already tried to delete my gradle caches but no luck.
Reacted by ken_kentan, Łukasz Suski, Jannis Kilian, Cristian Cristea, Miroslav Michalec, Marek Kubiczek, Sebastian Matuszczyk, Al Sutton, Martin Morset and Andrii Volynets
I'm facing same problem.
My project uses Composite build, and it seems that Kotlin version used in Composite build is not the same as Kotlin version used in Hilt Plugin.
The same on my project. I have kotlin 2.2.0 everywhere but it seems like Gradle and maybe kotlin-dsl plugin use kotlin 2.1.20. This is what I see from dependencies task. Maybe this is more like Gradle issue
The resolution is to ask dagger hilt to add apiVersion=1.8, languageVersion=apiVersion, and coreLibrariesVesion=1.8, so it supports backward compatibility
Apparently it should also be possible to use kotlin("jvm") plugin instead of kotlin-dsl but I failed so far.
I eventually managed to migrate my plugin modules to use kotlin.jvm instead of kotlin-dsl plugin. Now they're decoupled from the Kotlin shipped with Gradle.
Followed this great article: https://mbonnin.net/2025-07-10_the_case_against_kotlin_dsl/
DaggerConventionPlugin misses coreLibrariesVersion. It should be there so kotlin("jvm") configures a proper dependency on kotlin-stdlib-$target otherwise the added dependency would still refer a newer kotlin-stdlib. I think this block could be replaced with coreLibrariesVersion setting:
DaggerConventionPlugin does not properly configure Kotlin compiler to target Java 1.8. It should be using Xjdk-release=8 rather than jvmTarget. The difference is that Xjdk-release properly accounts for Java 1.8 public API. Currently, it looks like the build tries to use old JDK toolchain which might result in compilation failures. At best, the build should use the newest LTS compiler (e.g. Java 21) and it should target the desired release with javac --release and kotlinc -Xjdk-release.
Are there some instructions on how to do that? Unfortunately our build system uses Gradle plugins, and a simple version bump ends up with;
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.dagger.hilt.android', version: 'HEAD-SNAPSHOT', apply: false] was not found in any of the following sources:
Activity
NUmeroAndDev commentedon Jul 22, 2025
I'm facing same problem.
My project uses Composite build, and it seems that Kotlin version used in Composite build is not the same as Kotlin version used in Hilt Plugin.
danysantiago commentedon Jul 22, 2025
Hi - Can you double check which version of Kotlin you have in your 'buildSrc' project and in the other composite build projects?
The error message seems to indicate that you are still in Kotlin 2.0.0, but Hilt has upgraded to 2.2.0.
lsuski commentedon Jul 22, 2025
The same on my project. I have kotlin 2.2.0 everywhere but it seems like Gradle and maybe kotlin-dsl plugin use kotlin 2.1.20. This is what I see from dependencies task. Maybe this is more like Gradle issue
ArthurKun21 commentedon Jul 23, 2025
AGP: 8.11.0
Kotlin: 2.2.0
Gradle Wrapper: 8.14.1
I've tried earlier Gradle 9.0.0 RC3 which has Kotlin 2.2 and it still failed
https://github.com/gradle/gradle/releases/tag/v9.0.0-RC3
https://docs.gradle.org/9.0.0-rc-3/release-notes.html
edit:
okay, I need to update to 9.0.0-RC3 first before updating the dagger hilt
mar3kk commentedon Jul 23, 2025
Same issue here. Bumping Gradle to 9.0.0-rc-3 fixed this issue for me, but we don't wanna switch to it just yet.
Asked this question on Gradle Slack: https://gradle-community.slack.com/archives/CAD95CR62/p1753211835993559
Someone answered:
Apparently it should also be possible to use
kotlin("jvm")plugin instead ofkotlin-dslbut I failed so far.alluhemanth commentedon Jul 23, 2025
Apparently upgrading
kotlin-dslworked for me.AGP: 8.11.1
Kotlin: 2.2.0
Gradle Wrapper: 8.14.3
And I changed from
plugins { `kotlin-dsl` }to
plugins { `kotlin-dsl` version "6.2.0" }mar3kk commentedon Jul 23, 2025
I eventually managed to migrate my plugin modules to use
kotlin.jvminstead ofkotlin-dslplugin. Now they're decoupled from the Kotlin shipped with Gradle.Followed this great article: https://mbonnin.net/2025-07-10_the_case_against_kotlin_dsl/
vlsi commentedon Jul 23, 2025
In theory, a part of the build uses
apiVersionandlanguageVersion:dagger/buildSrc/src/main/kotlin/dagger/gradle/build/DaggerConventionPlugin.kt
Lines 174 to 175 in 1702e79
However, there are several issues still present:
hilt-android-gradle-pluginmisses that configuration, so it lacksapiVersionandlanguageVersionaltogether:dagger/java/dagger/hilt/android/plugin/build.gradle
Line 6 in 1702e79
DaggerConventionPluginmissescoreLibrariesVersion. It should be there sokotlin("jvm")configures a proper dependency onkotlin-stdlib-$targetotherwise the added dependency would still refer a newerkotlin-stdlib. I think this block could be replaced withcoreLibrariesVersionsetting:dagger/java/dagger/hilt/android/plugin/build.gradle
Lines 31 to 39 in 1702e79
DaggerConventionPlugindoes not properly configure Kotlin compiler to target Java 1.8. It should be usingXjdk-release=8rather thanjvmTarget. The difference is thatXjdk-releaseproperly accounts for Java 1.8 public API. Currently, it looks like the build tries to use old JDK toolchain which might result in compilation failures. At best, the build should use the newest LTS compiler (e.g. Java 21) and it should target the desired release withjavac --releaseandkotlinc -Xjdk-release.Use specific api / language versions for Kotlin compilation of the Hi…
Use specific api / language versions for Kotlin compilation of the Hi…
Use specific api / language versions for Kotlin compilation of the Hi…
Use specific api / language versions for Kotlin compilation of the Hi…
Use specific api / language versions for Kotlin compilation of the Hi…
Use specific api / language versions for Kotlin compilation of the Hi…
Set coreLibrariesVersion as that also helps with backwards compatibil…
Set coreLibrariesVersion as that also helps with backwards compatibil…
Set coreLibrariesVersion as that also helps with backwards compatibil…
bcorso commentedon Jul 29, 2025
This should be fixed at head.
If someone could verify the fix with the HEAD-SNAPSHOT artifacts, that would be great. Otherwise, we'll try to do another release next week.
alsutton commentedon Jul 31, 2025
Are there some instructions on how to do that? Unfortunately our build system uses Gradle plugins, and a simple version bump ends up with;
bcorso commentedon Jul 31, 2025
@alsutton Did you update your repositories to include the maven snapshots url?