📑
android 古いライブラリを最新にバージョンアップしたらよくわからないバグまみれになってビルドできなくなった
状況
古いアプリの改修をしており、
様々なライブラリを最新バージョンにして改修をしている際に
よくわからないエラーまみれになってビルドができなくなってしまった
エラー内容
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)
(参考記事のものを転用してます)
対処法
build.gradleに
configurations {
cleanedAnnotations
compile.exclude group: 'org.jetbrains' , module:'annotations'
}
を追加することで解決できた
参考記事
Discussion