Where Kotlin version in lintAnalyzeDebug comes from?
Asked Answered
S

2

7

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?

Synaesthesia answered 14/7, 2023 at 17:44 Comment(0)
L
8

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

Lithomarge answered 25/7, 2023 at 14:17 Comment(1)
Really well dug out! Can be next to impossible to find solutions to these obscure problems.Logician
A
0

This is for 1.7.1 to 1.9.0 error but it works for all Kotlin versions

The first step check into File->Settings-> Plugins -> Kotlin your version (for this example 1.9.2).

Now go to gradle->builde.gradle and set into

buildscript ->
 ext.kotlin_version = '1.9.0'

add these two under repositories ->

gradlePluinPortal() 
mavenCentral()

add under repositories ->allprojects-> mavenCentral() Now rebuild projet.

Aldus answered 13/9 at 11:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.