Updated to Android Studio 3.0. Getting a "Kotlin not configured" error
Asked Answered
F

19

60

I just updated to Android Studio 3.0 and I'm getting this error with an existing project:

Kotlin not configured

When I go to Tools>Kotlin>Configure Kotlin in Project, I get an error saying "no configurators available". Also get the error below with the red java:

enter image description here

I've also tried:

  • Restarting
  • Clean and Rebuild
  • Invalidate caches/restart.
Fleury answered 8/11, 2017 at 1:28 Comment(5)
Try a clean build from CLI, it worked for me: close Android Studio and run ./gradlew clean assembleDebug then start Android Studio again.Steviestevy
This worked for me. You should add it as an answerTabber
thanks @m3dw3 . It worked for me. I faced this issue after changing my .gradle directory path.Panier
In my newly created project (via Android Studio 3.2.1 stable), I had following kotlin version defined in project's build.gradle: ext.kotlin_version = '1.3.11' '1.2.71'. I removed the second version and so it looked like this ext.kotlin_version = '1.3.11'.Bootless
File -> Sync Project with Gradle files worked for me ...Unrealizable
S
48

I first tried with invalidate cache/ restart option but it doesn't help me.

When I updated Kotlin to 1.1.60 in project's gradle file, problem is solved.

Also, use this in app's gradle for stdlib

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.1.60" 

instead of

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60"
Succentor answered 27/11, 2017 at 7:53 Comment(3)
A few lines of context to know where the line need to be replaced would have been nice.Thermophone
I tried this which I thought resolved the issue. However, when I reverted to my original implementation implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" the error was still resolved. I must of just needed to have the gradle file re0run.Legendary
Thanks! Removing jre7 from dependency helped me to sync and finally build project with a new Kotlin version.Marcelmarcela
R
40

In Android Studio, click on File -> Invalidate Caches / Restart... , then select "Invalidated and Restart". This solved my problem.

Revenue answered 11/5, 2018 at 9:44 Comment(2)
This answer is not specific to Mac. It also worked on my Windows machine.Holley
This answer works for me. It should be the approved oneHersh
G
13

This error also occurs if you have the mavenCentral() repository missing in allprojects. Your build.gradle (:app) should contain at least this:

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

jcenter() would work as well (for now), but that repository reached end-of-life and shouldn't be used any more.

Glance answered 24/6, 2021 at 21:20 Comment(0)
A
4

Closing and restarting Android Studio works for me in that case. Important is that there are no other projects opened in Android Studio before you close it. I suspect that closing Android Studio with multiple opened project windows sometimes messes up the configuration especially after plugin upgrades etc.

And answered 29/11, 2017 at 18:12 Comment(0)
G
3

Important Update

You should check JDK version before setting config

Kotlin gradle config page has detailed information about this.

Step 1

Check kotlin version in project level gradle file.

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

For kotlin_version '1.2.x' Use jdk NOT jre

Step 2

Check JDK version in File > Project Structure

sc

Or check in build.gradle

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

If no JDK version is set in Project Structure, then choose by Android Studio version

  • JDK version is 1.7 for Android Studio Version < 2.2.1
  • JDK version is 1.8 for Android Studio Version < 2.2.1

Because Android Studio is bundled with jdk 1.8 since 2.2.1 version.

You have 3 options of kotlin stdlib, choose according JDK version

implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //jdk_version == 1.8
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" //jdk_version == 1.7
implementation"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // jdk_version is < 1.7

if kotlin version is'1.1.x' Use jre NOT jdk

implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // or jre8

Update Kotlin Version?

You can update Kotlin version from Tools > Kotlin > Configure Kotlin Updates

Grazier answered 22/11, 2018 at 10:57 Comment(0)
P
3

Kotlin-stdlib-jre7 is deprecated since 1.2.0 and should be replaced with kotlin-stdlib-jdk7

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 
Parmesan answered 14/3, 2019 at 5:56 Comment(0)
D
3

A common reason of the "Kotlin Not Configured" message is an internal Android Studio exception due to a bad plugin. In order to fix that you should disable the bad plugin.

When such plugin crash occurs, on the "Wellcome screen" you'll see a small notification (see illustration image) where you can click it and disable the bad plugin:

enter image description here

Disquiet answered 10/12, 2020 at 12:22 Comment(0)
T
2

I have faced this issue recently... when I updated to Android Studio 3.1 .

I did a few things to fix this.

  1. First I updated the Kotlin version in my app gradle file and added

    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.31" 
    

    in my app gradle file. But this alone didn't fix it.

  2. Then uninstalled the kotlin plugin from settings, restarted Android Studio and installed it again.

EDIT :

This is my project gradle file

buildscript {
   ext.kotlin_version = '1.2.31'
   repositories {
      jcenter()
      google()
    }
   dependencies {
      classpath 'com.android.tools.build:gradle:3.1.1'
      classpath 'com.google.gms:google-services:3.1.0'
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"

   }
 }

allprojects {
   repositories {
      jcenter()
      maven { url "https://jitpack.io" }
      google()
   }
}

And this is my app gradle file

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {

   compileSdkVersion 27

   buildToolsVersion '27.0.3'

   defaultConfig {
       ...
    }

    buildTypes {
        ...
    }

    sourceSets {
         main.java.srcDirs += 'src/main/kotlin'
     }

     kapt { generateStubs = true }


}
repositories {
     ...
}


dependencies {
    ...
    ...
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.31"
    ...
    ...

 }

apply plugin: 'com.google.gms.google-services'
Track answered 27/3, 2018 at 12:12 Comment(1)
A few lines of context to know where the line goes would have been nice.Thermophone
S
2

just delete .idea folder from project,and run android studio again, it will resolve KOTLIN NOT CONFIGURED issue.

Smaze answered 16/9, 2020 at 16:49 Comment(0)
T
1

None of the other solutions solved my problem. I ended up figuring out that the problem lied in the google services version. Just update it to the latest.

Top level gradle at dependencies:

classpath 'com.google.gms:google-services:4.1.0'
Tauro answered 13/11, 2018 at 9:55 Comment(0)
F
1

In my case, after the update of Android Studio and plugins, I could create new projects, but my old projects were having "Gradle Sync Issues".

The solution was in File/Project Structure.../App/Dependencies:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 

And then I just updated the Kotlin version in my project build.gradle:

From:

ext.kotlin_version = '1.2.30'

To:

ext.kotlin_version = '1.3.21'

Then I tried Sync again.

Obs: You can check your Kotlin version in Tools/Kotlin/Configure Kotlin Plugin Updates

Fractostratus answered 18/3, 2019 at 23:38 Comment(0)
T
1

I have tried all above solutions but non of them works for me.

Then finally I got success with below solution, so it may helpful for some one like me.

  1. Delele all .iml files (in root project, libraries and modules)
  2. Rebuild project
Tachograph answered 24/6, 2019 at 11:39 Comment(0)
L
1

In my case I had to update Android studio from version 3.4.1. to 3.5 and it resolved the kotlin not configured error.

Lippmann answered 13/9, 2019 at 6:58 Comment(0)
H
1

Delete .AndroidStudio3.6 folder in C:\Users\Username and re-open Android studio works for me

Hapsburg answered 6/3, 2020 at 11:9 Comment(0)
S
1

The only fix for me was adding

apply plugin: 'kotlin-android-extensions'

in build.gradle (:app)

Stratum answered 17/6, 2020 at 10:18 Comment(0)
B
0

One other point to check is version of your Gradle in gradle-wrapper.properties, if you use one.

Make sure that distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Has version 4.1 or higher.

You may also have the following in your build.gradle:

task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
    distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}

Where Gradle version is lower that 4.1

Bremble answered 23/5, 2019 at 9:26 Comment(0)
G
0

Though I see that the question already has answers that work, one might also try the following solution.

Right click on the file name (Main.kt) -> Run 'Main.kt'.

This will download a gradle file from the gradle.org website.

Wait for it to unzip. The errors were cleared.

Guanabana answered 29/6, 2019 at 17:30 Comment(0)
R
0

In my case, it was a broken update of one of the plugins I've used. Check your error logs from Android Studio this will lead you to what is the problem.

Reinaldo answered 17/7, 2020 at 16:56 Comment(0)
S
-1

Simply Create a new Activity and select its language to kotlin Android studio Automatically configured kotlin for you.

Surtax answered 21/5, 2020 at 6:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.