【问题标题】:Kotlin not configured after updating android studio & gradle plugin更新 android studio & gradle 插件后未配置 Kotlin
【发布时间】:2020-07-17 15:52:47
【问题描述】:

这是 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 plugin version (4.0.1) & gradle version (6.5.1)

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

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

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

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

我仍然有 Kotlin 未配置的问题,非常感谢任何帮助。

【问题讨论】:

    标签: android kotlin gradle


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      使用 kotlin lang 创建一个新的活动,它会自动配置 kotlin

      【讨论】:

      • 对我不起作用
      猜你喜欢
      • 2021-04-28
      • 1970-01-01
      • 1970-01-01
      • 2018-03-30
      • 2022-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多