我最近刚开始使用kotlin进行android开发,所以对android studio也是个十足的noob.我正试图构建一个超级简单的HelloWorld应用,但我得到了这个错误。
Annotation processors must be explicitly declared now. 在编译classpath上发现以下依赖项包含注解处理器。 请将它们添加到annotationProcessor配置中。 - jetified-kotlin-compiler-embeddable-1.3.72.jar(kotlin-compiler-embeddable-1.3.72.jar)另外,设置android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath=true,继续之前的行为。 请注意,这个选项已被废弃,并将在未来被删除。 请看 https:/developer.android.comrtoolsannotation-processor-error-message.html。 了解更多细节。
但当我在我的依赖关系的结尾添加注释处理器时,比如。
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"
}
当我试图构建时,我遇到了一个新的错误。
类重复错误可以通过清理项目来解决。首先清理项目,然后重建项目。