Updated to Android Studio 3.0. Getting a “Kotlin not configured” error

后端 未结 19 938
挽巷
挽巷 2020-12-18 17:59

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

19条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 18:39

    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

    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

提交回复
热议问题