Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
}
like image 329
Marco Rodriguez Avatar asked Jul 26 '19 23:07

Marco Rodriguez


People also ask

How do I change project Kotlin version?

Go to Intellij Preferences -> Build, Execution, Deployment -> Kotlin Compiler. Update Language version and Api version to the one you wish. This should be the accepted answer.

In which file do we change the version of Kotlin in your Android app build Gradle?

Select your module in the Project window, and then select File > New, select any Android template, and then choose Kotlin as the Source language.


1 Answers

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.

like image 138
CommonsWare Avatar answered Nov 02 '22 18:11

CommonsWare