본문 바로가기

프로그래밍/Android

[Android|Kotlin] Gradle Sync Issue: Android Gradle plugin supports only Kotlin Gradle plugin version ... and higher

반응형

안드로이드 스튜디오를 사용하여, 코틀린을 좀 배워보려고, 인터넷에 있는 예제를 받아서 빌드해 보려고 하는데 에러가 발생했다. 처음 접하는 환경이라서 이 복잡한 메시지가 무슨 말인지, 무엇을 고쳐야 하는 것인지 이해할 수 없었다. 이를 기록한다.

예제 폴더를 안드로이드 스튜디오에서 Open 으로 열었고, 무작정 Run 버튼을 눌러보았다. 프로젝트를 한참 빌드하다가 다음과 같은 메시지의 에러 윈도우가 떴다.

Android Gradle Plugin Update Required
-------------------------------------

The Project is using an imcompatible version of Android Gradle plugin.

To continue opening the project, the IDE will udpate the plugin to version 3.5.1.

You can learn more about this version of the plugin from the release notes.


                              [Update] [Cancel and update manually]

gradle 플러그인을 업데이트해야 한다는 메시지인데, gradle 이 무엇인지에 대한 개념도 없었다. 무작정 update 버튼을 눌렀다.

다시 조금 무언가가 진행되다가 빨간색으로 다음과 같은 메시지가 떴다.

Gradle Sync Issues:

ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
root project 'Chapter03' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51
Update plugins

Affected Modules: app

Update plugins 부분이 클릭할 수 있는 링크여서, 링크를 눌러보면 트리형태로 다음과 같이 에러의 원인이 되는 소스라인을 알려준다.

build.gradle
      11  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

classpath 로 시작되는 부분을 더블클릭하면, gradle 소스파일이 나타난다. 안드로이드는 java나 kotlin 소스라는 것만 알고 있어서, gradle 이라는 생소한 소스가 나와서 당황스러웠다. 뭘 고쳐야 하는 걸까?

buildscript {
    ext.kotlin_version = '1.2.51'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"    /// <<<<< 

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

 

Gradle Sync Issue 로 시작되는 에러메시지를 다시 잘 해석해 보자.

안드로이드 Gradle 플러그인이 코틀린 Gradle 플러그인 1.3.10 이상만 지원한다.
다음 의존성이 필수 버전을 만족하지 않는다.:
루트 프로젝트 'Chaper03' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51

위 소스에서 보면, kotlin_version 이 1.2.51 로 지정되어 있고, 이 변수가 $kotline_version 으로 kotlin-gradle-plugin 뒤에 쓰여 있다는 걸 알 수 있다. 이 값이 너무 낮다는 이야기 같다. 그래서, kotline_version 을 1.3.10 으로 바꾸었다.

값을 바꾸고, gradle sync 작업을 다시 하니(Try Again 을 눌렀음.) 문제가 해결되었다.

728x90