Android编译报错 jetified-annotations

android studio升级到 Arctic Fox (2020.3.1),相应gradle插件升级到7.0.0之后,出现重复类,因为不同版本的jar包,如下:

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class org.intellij.lang.annotations.Identifier found in modules jetified-annotations-12.0 (com.intellij:annotations:12.0) and jetified-annotations-21.0.1 (org.jetbrains:annotations:21.0.1)

原因:
使用了jetbrains的一些注解,但是使用的不同jar中的
解决方案:
在app的build.gradle中增加如下的exclude(只能exclude一个,不能两个都exclude):

android {
    configurations {
        cleanedAnnotations
        // implementation.exclude group: 'org.jetbrains' , module:'annotations'
        implementation.exclude group: 'com.intellij' , module:'annotations'
    }
}

你可能感兴趣的:(Android编译报错 jetified-annotations)