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?
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.
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).
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
...
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.
changing your ext.kotlin_version from '1.1.2-4'to ext.kotlin_version = '1.1.2-5' solved the problem for me
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
}
}
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
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
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
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
}
}
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 :)
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
}
}
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.
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
}
}
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.
Success story sharing