输出文本:
Execution failed for task ':app:checkDebugDuplicateClasses'.
1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class org.intellij.lang.annotations.Flow found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.Identifier found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$AdjustableOrientation found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$BoxLayoutAxis found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$CalendarMonth found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$CursorType found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$FlowLayoutAlignment found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$FontStyle found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$HorizontalAlignment found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$InputEventMask found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$ListSelectionMode found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$PatternFlags found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$TabLayoutPolicy found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
Duplicate class org.intellij.lang.annotations.JdkConstants$TabPlacement found in modules annotations-16.0.1.jar (org.jetbrains:annotations:16.0.1) and annotations-java5-15.0.jar (org.jetbrains:annotations-java5:15.0)
4条答案
按热度按时间bxjv4tth1#
这是两个jar之间的冲突,您可以从Modules_annotation 16.XXX和annotations-java 5-XXXX jar文件中找出您没有使用的jar。
我找到了两个解决办法。
1.排除JetBrains注解模块是一种变通方案;为什么它会出现在您的项目中?最有可能的情况是,当您真正需要的是Android自己的注解时,它被Android Studio自动添加到了您的类路径中。
因此,更好的解决方案是在您的build.gradle文件中查找org.jetbrains:annotations依赖项,如下所示:
......并将其移除。
如果1不工作
1.请在模块级build. gradle中添加以下行。
r1wp621o2#
Harsh Mishra's答案是正确的,但是最新版本的Android Studio不再在您的gradle依赖项中声明
org.jetbrains:annotations-java5:15.0
或org.jetbrains.kotlin:kotlin-stdlib:$version_kotlin
,并且compile的使用也被implementation所取代,因此您的build.gradle应如下所示:hgc7kmma3#
我通过更改
到
fjnneemd4#
这是两个不同的lib/jar文件中的单个工件之间的冲突。基本上我们需要删除未使用的lib或从任何一个lib中删除工件。
从Kotlin1.4开始,您不再需要以下依赖项
因此,删除此依赖项也将解决此问题。