首页 > 解决方案 > 更新 android studio & gradle 插件后未配置 Kotlin

问题描述

这是 build.gradle 项目文件:

buildscript {
    ext.kotlin_version = '1.3.72'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.72'
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
repositories {
    mavenCentral()
}
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

这是 build.gradle 应用文件:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-kapt'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "ze.app.xyzmath"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 2
        versionName "2.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding { enabled = true }
}

dependencies {
    def nav_version = "2.3.0"
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.3.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.google.firebase:firebase-common-ktx:19.3.0'
    implementation "com.android.support:support-compat:28.0.0"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.fragment:fragment-ktx:1.2.5'
    implementation 'com.opencsv:opencsv:4.6'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.room:room-runtime:2.2.5'
    annotationProcessor 'androidx.room:room-compiler:2.2.5'
    implementation 'com.google.android.gms:play-services-games:19.0.0'
    implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0'
    implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
}

Android gradle 插件版本 (4.0.1) & gradle 版本 (6.5.1)

我也无法打开文件->设置,我单击它但没有打开任何窗口。

我试过“为项目配置 Kotlin”,它说没有可用的配置器。

我尝试过重建、清理、无效和重新启动。

我在 stackoverflow 上尝试了许多以前的解决方案,但没有一个成功。

我仍然有 Kotlin 未配置问题,任何帮助将不胜感激。

标签: androidkotlingradle

解决方案


已解决 - 删除 C:\Users\YourUserName 中的 .AndroidStudio4.0 目录

Android Studio 将自动创建一个新的,没有问题。


推荐阅读