183

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
  • 484,302
  • 314
  • 1,365
  • 1,393
raditya gumay
  • 2,951
  • 3
  • 17
  • 24
  • 44
    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

8 Answers8

311

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,564
  • 146
  • 81
  • 122
jpihl
  • 7,941
  • 3
  • 37
  • 50
  • 1
    Yes, perfect Thank you, should be marked as right answer – India Jul 24 '18 at 11:05
  • 3
    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
  • 2
    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
101

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
  • 527
  • 2
  • 6
  • 20
RoCkDevstack
  • 3,517
  • 7
  • 34
  • 56
  • 4
    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
  • 92,896
  • 20
  • 260
  • 197
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,824
  • 17
  • 99
  • 186
user158
  • 12,852
  • 7
  • 62
  • 94
2

1): Open your project in Android mode.

2): Go to build.gradle file(Project: android) level, which is also located below the gradle folder in Project mode and open it.

3): It will start with something like this

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

4): See that in above example that the

ext.kotlin_version = '1.7.10'

5): Now go to File menu in the Top-Left of Android Studio and open Settings.

6): Click on Plugins and select Installed on the top of the settings window.

7): Now scroll down to Kotlin, select it and see it's version, for example:-

221-1.8.0-release-for-android-studio-AS5591.52.

8): Here 1.8.0 is your Android Studio Kotlin plugin version, which is different from your ext.kotlin_version in build.gradle.

9): So, just make your ex.kotlin_version same as Kotlin plugin version and you're good to go!

10): In above example the ex.kotlin_version = is '1.7.10 and Kotlin Plugin version is '1.8.0'. If I type '1.8.0' in my ex.kotlin_version, making my plugin version same as ex.kotlin_version and sync it, the issue gets resolved. Hope this helps!, I,m also new in flutter.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
1

Go to plugins then uninstall kotlin then restart ide then once android studio is back up drop down tools then select kotline then configure updates, it should be checking for new updates.

  • This worked for me. Before uninstalling Kotlin plugin, the bundled version was 1.7.10, which was giving me errors. After reinstalling, it was 1.6.10, which works. – Bob Liberatore Sep 10 '22 at 16:32
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
  • 1,009
  • 10
  • 16
-1

[![In my case I had to downgrade to Gradle 7.2.2

]1]1

And I'm using stable Kotlin version