简体   繁体   中英

Android Stuido: How to change Kotlin version that is used for building with Gradle

Android Studio is giving a warning saying: "Kotlin version that is used for building with Gradle (1.3.10) differs from the one bundled into the IDE plugin (1.3.41)".

How can i change the Kotlin version used by Gradle?

I have installed the latest Android Studio version(3.4.2) with the latest Kotlin plugin(1.3.41-release-Studio3.4-1)

I have also tried to change the kotlin version in the build.gradle file, but its saved in a variable "kotlin_version$"

dependencies {
    // ....
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

I have also tried to change the kotlin version in the build.gradle file, but its saved in a variable "kotlin_version$"

That variable is defined earlier in the file. Here is a typical top-level build.gradle file:

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The second line of that file is:

    ext.kotlin_version = '1.3.41'

That is where kotlin_version is defined, that is then used in "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" .

So, change ext.kotlin_version to be the value that you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM