Android studio 在添加 annotationProcessor 时抛出重复的 class 错误

Android studio throws a duplicate class error when annotationProcessor is added

我最近刚开始使用 kotlin 进行 android 开发,所以在 android 工作室也是个菜鸟。 我正在尝试构建一个超级简单的 HelloWorld 应用程序,但出现此错误:

Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - jetified-kotlin-compiler-embeddable-1.3.72.jar (kotlin-compiler-embeddable-1.3.72.jar) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

但是当我在依赖项的末尾添加注释处理器时,如:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    annotationProcessor "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"

}

我在尝试构建时遇到了一个新错误:

https://del.dog/pyfunestin

Class 可以通过清理项目来解决重复错误。首先清理项目并重建它。