ChatGPT解决这个技术问题 Extra ChatGPT

Outdated Kotlin Runtime warning in Android Studio

After downloaded and installed latest Kotlin plugin I have Outdated Kotlin Runtime warning from Android Studio that telling me:

Your version of Kotlin runtime in 'kotlin-stdlib-1.1.2' library is 1.1.2, while plugin version is 1.1.2-release-Studio2.3-3. Runtime library should be updated to avoid compatibility problems.

I tried to click Update Runtime button but getting another message:

Automatic library version update for Gradle projects is currently unsupported. Please update your build.gradle manually.

How to solve this issue?


I
Ivo Stoyanov

https://i.stack.imgur.com/VDN8R.png

In order to check which is the current version of your Kotlin plugin:

Go to: Tools -> Kotlin -> Confugure Kotlin Plugin Updates Click "Check again". After a second you will see the version of your Kotlin plugin. (If not up to date, your Kotlin plugin will be updated.)

N.B.: Also check your (Module: app) build.gradle file and assure that you do not use:

compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.21" 

but

compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.40'

Note the difference "...jre7..." -> "...jdk7...". Also replace "1.2.40" with your current Kotlin plugin version.


Thank you helped me to update my Koltin plugin by doing Tools->Kotlin-->Configure Kotlin Updates-> Check for updates->Install.
This should be accepted answer!! I'm using Android Studio 3.1.3, I had same issue like OP
remember to use 1.3.31
G
Gastón Saillén

You can update your Kotlin version in your project level build.gradle file. If you have it configured the usual way, you should have the following line in it around the top:

ext.kotlin_version = '1.1.2'

To upgrade to the version matching your plugin, simply change this line to:

ext.kotlin_version = '1.1.2-3'

Edit (to respond to a question below):

The error tells you that you need to upgrade your version, the question is where to find out that you have to put in 1.1.2-3 instead of saying, for example, 1.1.2-release-Studio2.3-3.

The best way to find out the latest version of Kotlin is by going to kotlinlang.org and looking for "Latest version". Should be right there on the front page.

Another thing to do if the version number is non-trivial like this is to check the repositories where the versions are hosted. In the case of Android, you'll probably be getting it from jcenter, for which you can find the repository page, which has all the available versions listed.

You can also browse the raw maven repository of jcenter where the files are actually hosted by going here, or look up Kotlin either on mvnrepository or on mavencentral (raw version of the latter here).


Thanks, this is not clear at all from the error. How can I derive what to do, how did you find out?
Brilliant! I've been ignoring this warning for awhile now because I couldn't find how to do this.
For anyone like me, there are two "build.gradle" in your project, make sure you checked the project level file.
M
Martin Zeitler

it complained (on Android Studio 3.0.1) ...most likely because of referenced libraries' dependencies:

Your version of Kotlin runtime in 'org.jetbrains.kotlin:kotlin-stdlib:1.1.3@jar' library is 1.1.3, while plugin version is 1.1.51-release-Studio3.0-1.

then I've enforced building against the version it demanded, in the module level build.gradle:

configurations.all() {
    resolutionStrategy.force 'org.jetbrains.kotlin:kotlin-stdlib:1.1.51'
}

and the result is:

./gradlew app:dependencies | grep kotlin
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.51/kotlin-stdlib-1.1.51.pom
 |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3 -> 1.1.51
 ...

a
auspicious99

There are two pieces you may want to update:

kotlin runtime for the project kotlin plugin

The answer by Ivo Stoyanov shows how to do this using the android studio menus. When I got the error message and tried this (updating the kotlin plugin) alone, it still complained about the kotlin runtime. You can update that on a project by project basis, by adding the line on ext.kotlin_version to the project build gradle, as some of the other answers indicate. But you'll need to know the kotlin runtime version for that. Alternatively, you can also do it through the menus, as I show here below, with the bonus that android studio shows you the available versions, and you can pick the most recent.

https://i.stack.imgur.com/MSrVW.png

https://i.stack.imgur.com/d1g7n.png

https://i.stack.imgur.com/tzphA.png

https://i.stack.imgur.com/EYFVu.png

And then android studio will add in the appropriate line in your project build gradle.


M
Mauve Guava

changing your ext.kotlin_version from '1.1.2-4'to ext.kotlin_version = '1.1.2-5' solved the problem for me


do kotlin plugin not support automatic plugin update?? it shows to update gradle manually
it shows "Your version of Kotlin runtime in 'kotlin-stdlib-1.1.2-5' library is 1.1.2-5, while plugin version is 1.1.3-release-Studio2.3-1.Runtime library should be updated to avoid compatibility problems." .... what should i supposed to do now.
changing your ext.kotlin_version from '1.1.2-5'to ext.kotlin_version = '1.1.3-1'
a
abhilasha Yadav

the latest version of kotlin is 1.2.41 use this and syn your project.

buildscript {
ext.kotlin_version = '1.2.41'
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    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
}
}

It is now 1.2.51 on July 5; see my answer for an easy way to see what the latest version is.
r
ralphgabb

As of March 8, 2019 the current kotlin version is '1.3.21'

Under build.gradle

buildscript {
   ext.kotlin_version = '1.3.21'
   repositories {
      google()
      jcenter()
   }
   dependencies {
      classpath 'com.android.tools.build:gradle:3.3.2'
      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
}

cheers


T
TapanHP

This issue comes when you update the kotlin plugin version popped up from android studio, but issue is current version of Android studio is not able to dynamically change the kotlin gradle plugin which is located in your project level Build.gradle file.

dependencies {
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10"
}

How to solve this issue?

So you need to manually change this version, You can find that Here


The kotlin runtime and kotlin plugin are different. The question was asking about the error message that asks to update the kotlin runtime.
S
Sal Aldana

I've run into this issue a few times in Android Studio and IDEA, found that if you go into your projects Gradle file and in your dependencies if you set the version of the kotlin-gradle-plugin to $kotlin_version then the warning message will tell you what version you need to set ext.kotlin_version to.

buildscript {
ext.kotlin_version = '1.2.40'
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    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
}
}

https://i.stack.imgur.com/skTRw.png


w
wscourge
buildscript {
    ext.kotlin_version = '1.2.50'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        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
    }
}

M
Muhammad Awais Rashid

search for these two lines of code

ext.kotlin_version = '1.3.11'

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

replace $kotlin_version with actual value (here it's 1.3.11)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11"

after this your IDE will automatically suggest you the updated version

happy coding :)


a
abhilasha Yadav

Kotlin newest version:

buildscript {
    ext.kotlin_version = '1.2.41'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.google.gms:google-services:1.5.0-beta2'


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

It is now 1.2.51 on July 5; see my answer for an easy way to see what the latest version is.
V
Vishal Pawar

Bit annoying but studio acts like it some times. Below steps can fix the issue.

Go to

Settings -> Build, Execution, Development -> Gradle -> Use default gradle wrapper(recommended)

change this to Use local and back to Use default. Studio will ask about updating gradle after closing the settings windows.


N
Narendra.kr

I was facing same problem after updation my android studio from 3.0.1 to 3.2.1.My problem was solved after using this.

buildscript {
ext.kotlin_version = '1.2.51'
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://jitpack.io" }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.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
}

}


V
ViliusK

I had faced this issue on latest Android Studio from Canary channel. You might want to consider downgrading Android Studio to stable version as well.

It happened for me on Android Studio 3.0 RC1.