8

Has anyone got the message "Kotlin not Configured"

I'm sure I missed something, but for the most part I downloaded it, and just had it import my existing 2.x settings. I tried a simply copy/paste from a java class to a new Kotlin file, and that's where I'm at.

Here is my current top level build.gradle

buildscript {
    repositories {
        jcenter {
            url = "http://jcenter.bintray.com/"
        }
        maven {
            url = "https://maven.google.com"
        }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'

    }
}

allprojects {
    repositories {
        jcenter {
            url = "http://jcenter.bintray.com/"
        }
        maven {
            url = "https://maven.google.com"
        }
        mavenCentral()
    }
}

And then at the top of my module build file I have these two lines

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

The current error is "Plugin with id 'kotlin-android' not found"

4
  • Did you properly setup the gradle build, gradle plugin and kotlin plugin? If you aren't sure with those, you may need to show us someting about them so we can actually locate down the problem instead of making a wild guess.
    – glee8e
    Commented May 18, 2017 at 1:06
  • I added a *.kt file I then got the message up top saying Kotlin not configured. I think clicked on the Configure -> Android With Gradle I think selected All Modules with Kotlin Files -> Ok I hit "Sync now" because Gradle had changed And now it appears my Gradle file is broken because I get Error:(2, 0) Extension with name 'android' does not exist. I think the root cause is the following line in mobile/build.gradle apply plugin: 'kotlin-android'
    – Brian S
    Commented May 18, 2017 at 1:33
  • Would it make a difference that my project uses NDK, and I'm currently using the experimental gradle (0.9.2). Is it just not possible since I need the experimental for NDK?
    – Brian S
    Commented May 26, 2017 at 19:21
  • @GREnvoy seems to be not possible. At least I'm not finding any hints at how this could be done. We need something like kotlin-android-experimental or something to use with the gradle-experimental plugin.
    – Berkus
    Commented Oct 4, 2017 at 6:14

5 Answers 5

2

You're missing a Kotlin dependency in the dependencies block:

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
1
  • I added the line below and now get "Gradle YourModule project refresh failed, Error: Cause compileSdkVersion is not specified" classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
    – Brian S
    Commented May 19, 2017 at 15:36
1

That message has appeared in previous versions of Android Studio (before v.3.0) when Kotlin library was not among class paths in the gradle script.

Probably, when importing your project that had no Kotlin, you've got overlapping with previous settings that results in the fact that Kotlin has not been found.

Try to create a project from scratch, insert your Java code and convert it into Kotlin (Code > Convert Java File to Kotlin File)

Java -> Kotlin file converter

0

Usually the automatic configurator "just works", but take a look at whta it was trying to do: http://kotlinlang.org/docs/reference/using-gradle.html#targeting-android

3
  • I tried to follow these steps, but now get plugin with id 'kotlin-android' not found
    – Brian S
    Commented May 19, 2017 at 15:10
  • I added some of my config values to the post above
    – Brian S
    Commented May 19, 2017 at 15:12
  • I can get past the Kotlin not configured, but get errors with Gradle 3.5 and configured in my gradle-wrapper.properties and 2.3.2 in my build.gradle, I now get the error buildToolsVersion is not specified. Is this an issue with me having NDK and needing the experimental version?
    – Brian S
    Commented May 26, 2017 at 19:23
0

I had the same error. I solved it pretty simple: Modify build.gradle to force a gradle sync.

0

Simple. Just go to Tools -> Kotlin -> Configure kotlin in project. In the window that appears, click on Android with gradle. Let the project sync and you are good to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.