171

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?

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Arsenius
  • 4,972
  • 4
  • 26
  • 39

15 Answers15

149

In your (Project: [projectName]) build.gradle file find this: ext.kotlin_version = 'x.x.x' and replace x.x.x with the current version of your Kotlin plugin. enter image description here

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

  1. Go to: Tools -> Kotlin -> Confugure Kotlin Plugin Updates

  2. 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.) enter image description here enter image description here

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.

Ivo Stoyanov
  • 16,256
  • 8
  • 62
  • 65
145

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).

Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77
zsmb13
  • 85,752
  • 11
  • 221
  • 226
11

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
 ...
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
6

There are two pieces you may want to update:

  1. kotlin runtime for the project
  2. 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.

step 1

step 2

step 3

step 4

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

auspicious99
  • 3,902
  • 1
  • 44
  • 58
3

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 – Devil10 Jun 30 '17 at 13:38
  • 4
    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. – Devil10 Jun 30 '17 at 13:41
  • changing your ext.kotlin_version from '1.1.2-5'to ext.kotlin_version = '1.1.3-1' – Beatrice Lin Oct 24 '17 at 10:38
2

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
}
}
abhilasha Yadav
  • 217
  • 1
  • 9
2

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

ralphgabb
  • 10,298
  • 3
  • 47
  • 56
1

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

TapanHP
  • 5,969
  • 6
  • 37
  • 66
  • The kotlin runtime and kotlin plugin are different. The question was asking about the error message that asks to update the kotlin runtime. – auspicious99 Jul 05 '18 at 07:34
1

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
}
}

enter image description here

Sal Aldana
  • 1,235
  • 4
  • 17
  • 39
1
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
    }
}
wscourge
  • 10,657
  • 14
  • 59
  • 80
abhilasha Yadav
  • 217
  • 1
  • 9
1

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 :)

Awais Rashid
  • 109
  • 1
  • 3
0

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
    }
}
abhilasha Yadav
  • 217
  • 1
  • 9
0

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.

Vishal Pawar
  • 4,324
  • 4
  • 28
  • 54
0

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
}

}

Narendra.kr
  • 181
  • 3
  • 12
-1

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.

ViliusK
  • 11,345
  • 4
  • 67
  • 71