153

Has anyone solved this issue?

kotlin version that is used for building with gradle (1.1.2-5) differs from the one bundled into the IDE plugin (1.1.2-4)

I am using AS 3.0 Canary 4

Suragch
  • 428,106
  • 278
  • 1,284
  • 1,317
raditya gumay
  • 2,587
  • 3
  • 16
  • 23
  • 40
    Try either upgrading plug-in (Tools -> Kotlin -> Configure Kotlin Plugin Updates -> Check for updates now) or downgrading `ext.kotlin_version` in `build.gradle`. – Miha_x64 Jun 20 '17 at 08:21

5 Answers5

296

I followed Miha_x64's advice and upgraded the plugin which solved my problem:

Tools -> Kotlin -> Configure Kotlin Plugin Updates -> Check for updates now

My version of Android Studio is:

Android Studio 3.0.1
Build #AI-171.4443003, built on November 9, 2017
Pang
  • 9,073
  • 146
  • 84
  • 117
jpihl
  • 7,571
  • 3
  • 35
  • 49
  • 1
    Yes, perfect Thank you, should be marked as right answer – India Jul 24 '18 at 11:05
  • This is not working for me! When I follow these steps, AS tells me "You have the latest version of the plugin installed", but the installed version is 1.5.31, yet according to the Kotlin website, the latest version is 1.6.21..... Help! – Karolina Hagegård May 13 '22 at 12:11
  • @KarolinaHagegård unfortunately I don't have an answer for you, but if you ever do figure it out, please remember to post what you did to fix the issue. Maybe you can try reinstalling your AS? – jpihl May 16 '22 at 07:42
  • Oh yeah, I forgot to get back to this... I managed to solve it by putting the higher version of Kotlin in my `app/build.gradle` file, and then it worked! :) It was weird... But AS must have downloaded it while building, even thought it couldn't find it from the Tools menu!... I might post an answer about it later. – Karolina Hagegård May 17 '22 at 22:43
85

In my case, I converted Java to Kotlin and I have already Kotlin installed with lower version. So I updated it.

Tools -> Kotlin -> Configure Kotlin Plugin Updates then Check for updates now then choose Stable

Kotlin .

But it didn't update my version in the build.gradle file automatically. Because it detected a newer version and differs from the old one.

So I manually updated my version to the latest from

ext.kotlin_version = '1.0.0' to ext.kotlin_version = '1.2.41'

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
    }
}
murchu27
  • 409
  • 1
  • 5
  • 17
RoCk RoCk
  • 3,089
  • 6
  • 31
  • 55
  • 3
    It's really surprising that they have such a basic flaw in their setup that you can configure the classpath to the latest via a shell script in one place but not the other. – John Perry Aug 06 '18 at 13:37
  • 1
    Thank you, the point is after you update the plugin you must change the previous version into current version at `build.gradle` – Jimale Abdi Jun 29 '19 at 10:10
  • This worked for me, sugg: Anyone doing this might need to add "mavenCentral()" before jcentre() in 2 places. – Neail Oct 02 '21 at 06:22
  • This is not working for me! When I follow these steps, AS tells me "You have the latest version of the plugin installed", but the installed version is 1.5.31, yet according to the Kotlin website, the latest version is 1.6.21! Even after changing "stable" to "Early Access Preview", AS still doesn't find any newer version.... Help! – Karolina Hagegård May 13 '22 at 12:13
5

There's an issue in Android Studio 3.0 Canary 4 that prevents it from loading the updated version of the Kotlin plugin. You can ignore the warning shown by the Kotlin plugin in build.gradle until a newer version of Android Studio 3.0 is released.

yole
  • 87,251
  • 17
  • 245
  • 186
5

I also had the same issue, I am using Android Studio 3.2.1

Change the Kotlin version of your project build.gradle file(not module build.gradle file) to latest(at the moment it is 1.3.11)

ext.kotlin_version = '1.3.11'

then there will be notification call Kotlin migration, click Run migrations link on the notification.

halfer
  • 19,471
  • 17
  • 87
  • 173
user158
  • 11,548
  • 7
  • 56
  • 83
0

add this in your build gradle app

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
reza rahmad
  • 970
  • 9
  • 16