App노자

[Jetpack Compose] annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin 본문

Android/Framework, 이슈, 환경셋팅

[Jetpack Compose] annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin

앱의노예 2023. 9. 3. 21:31

1. 개요


/Users/name/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation-jvm/1.6.0/a7257339a052df0f91433cf9651231bbb802b502/annotation-jvm-1.6.0.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

Jetpack Compose를 기존 프로젝트에 추가하거나 신규 프로젝트를 만들 때 위와 같은 에러가 발생하는 경우가 있다

호환성에 관련된 문제이며 구글에 검색하면 여러 가지 방법이 나오지만 Jetpack Compose를 추가할 때 위에 에러가 발생하는 경우는 일반적인 방법과 해결방법이 조금은 달랐다

2. 해결 방법


buildscript {
    ext {
        compose_version = '1.1.1'
        kotlin_version = '1.6.10'
    }
}

plugins {
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
Compose Compiler Version	kotlin_version
1.3.0				1.7.10
1.3.0-rc01			1.7.10
1.3.0-beta01			1.7.10
1.2.0				1.7.0
1.2.0-rc01			1.6.21
1.2.0-beta03			1.6.21
1.2.0-alpha08			1.6.20
1.1.0				1.6.10
1.1.1				1.6.10
1.1.0-rc03			1.6.10

compose_version과 kotlin_version의 호환성의 문제 때문에 발생하는 에러이므로 단순히 한쪽 버전만 올리거나 내리는 것이 
호환성에 맞는 버전으로 변경한 후 Sync버튼을 누르면 해결이 된다