为 Android Studio Electric Eel 2022.1.1 配置 Kotlin

Kyl*_*les 9 android android-studio android-studio-electric-eel

当我更新到 Electric Eel 2022.1.1 时,每次创建新的 Kotlin 文件时,都会收到通知 warning Configure Kotlin Configure 'Name.app' module in 'Name' project asKotlin (Android with Gradle) module

我只使用过 Kotlin,没有使用过 Java。我是在更新后才开始收到此警告的。

在我单击链接配置为 Kotlin(带有 Gradle 的 Android)模块并选择包含 Kotlin 文件的所有模块: Name.app并将 Kotlin 编译器设置为1.8.0后,当我创建新文件时,它仍然会再次发出警告。

我需要担心这个警告还是可以忽略它?

这是我的 build.gradle (:app)

 plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}
android {
    namespace 'com.example.name'
    compileSdk 33
    defaultConfig {
        applicationId "com.example.name"
        minSdk 23
        targetSdk 33
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    buildFeatures {
        viewBinding true
    }
}
dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.7.0-alpha01'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.core:core-ktx:1.9.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Run Code Online (Sandbox Code Playgroud)

这是顶层build.gradle

plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}
Run Code Online (Sandbox Code Playgroud)

小智 1

这不是你应该担心的事情。我建议暂时坚持使用 Kotlin 1.8.0,因为升级可能会导致与其他一些依赖项的兼容性问题。主要是材质。另外, core-ktx 在您的依赖项中指定了 3 次,所以我认为这是您需要研究的内容