androidkotlingradleandroid-gradle-pluginkotlin-multiplatform

Where Kotlin version in lintAnalyzeDebug comes from?


I've upgraded from Kotlin 1.7 to Kotlin 1.9 in my KMM project. though I have Gradle 7.6 AGP 7.4.2

After the upgrade lintAnalyzeDebug task reports error on every dependency: 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.

I understand that I can disable the lint check, but I want to keep it if it is possible. I understand that the 1.7.1 is used by the version of Gradle. I cannot upgrade Gradle, because Idea does not work with Gradle 8 correctly. What I am not understand is why this error is thrown. Everything else works with Kotlin 1.9 well. Why only lint has problems?

Is there any place where I need to fix Kotlin version used for lint?


Solution

  • You can update the lint version used by adding:

    android.experimental.lint.version=8.1.0-rc01
    

    to gradle.properties.

    This is needed because the default lint version included in AGP 7.4.2 (and AGP 8.0.2 even) links with kotlin-compiler plugins for 1.7 which handles up to and including kotlin 1.8.
    So to support kotlin 1.9.x you need a lint version that at least links kotlin-compiler plugin 1.8, 8.1.0-rc01 for example.

    More information in this google tracker issue: https://issuetracker.google.com/issues/185418482