android - 添加注解处理器时,Android Studio会引发重复的类错误

标签 android android-studio kotlin kotlin-android-extensions

我最近才刚开始使用Kotlin进行android开发,所以在android studio上也很傻。
我正在尝试构建一个 super 简单的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

最佳答案

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

关于android - 添加注解处理器时,Android Studio会引发重复的类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61385895/

相关文章:

java - 列表首选项默认值不起作用 Android studio

kotlin - 如何将 Reactor Flux<String> 转换为 InputStream

android - 如何使用 Jetpack Compose 为复选框设置边框颜色

android - java.io.IOException : Cannot run program CreateProcess error=2, 系统找不到android studio上指定的文件

java - 销毁 Nuance session

android - 我如何安装支持库android?

Android Studio 4.1 插件错误 : Plugin * is incompatible (supported only in IntelliJ IDEA)

android - 缩放 X 轴 MPAndroidChart

java - 循环不会自动运行

安卓工作室 "No tests were found"