简体   繁体   中英

Android Studio 3 canary & Kotlin

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"

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

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

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文件转换器

通常,自动配置器“可以正常工作”,但请看一下它正在尝试执行的操作: http ://kotlinlang.org/docs/reference/using-gradle.html#targeting-android

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM