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

2

8

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"
}
Bromal answered 26/7, 2019 at 23:30 Comment(0)
U
11

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.

Unharness answered 26/7, 2019 at 23:34 Comment(3)
Thank you, it was very simple after all. :)Bromal
I'm using studio v2020.3.1 patch 3 ... kotlin_version is in build.gradle (Project) not build.gradle (Module)Partizan
@duanev: Correct! What I referred to as a "top-level build.gradle file" is what you referred to build.gradle (Project).Unharness
L
0

Maybe it would be useful for someone. Change inandroid/setting.gradle plugins{id "org.jetbrains.kotlin.android" version "1.9.25" apply false}

Lisandralisbeth answered 27/9, 2024 at 14:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.