【问题标题】:How can this error- Duplicate class error Dagger Hilt be solved?如何解决这个错误 - Duplicate class error Dagger Hilt?
【发布时间】:2020-12-13 02:26:00
【问题描述】:

我的应用程序中有不同的模块遵循干净的架构,一些是纯 kotlin 模块和其他 android 模块,但是当我尝试编译应用程序时,我得到了重复的类错误。

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class dagger.hilt.codegen.OriginatingElement found in modules jetified-hilt-android-2.28.3-alpha-runtime (com.google.dagger:hilt-android:2.28.3-alpha) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.hilt.processor.internal.aggregateddeps.AggregatedDeps found in modules jetified-hilt-android-2.28.3-alpha-runtime (com.google.dagger:hilt-android:2.28.3-alpha) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationMirrors found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationMirrors$1 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationMirrors$2 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1$1 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1$1$1 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1$1$2 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1$1$3 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1$1$4 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.AnnotationValues$1$2 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.BasicAnnotationProcessor found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.BasicAnnotationProcessor$1 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.BasicAnnotationProcessor$2 found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)
     Duplicate class dagger.shaded.auto.common.BasicAnnotationProcessor$ElementName found in the following modules: jetified-dagger-compiler-2.28.3 (com.google.dagger:dagger-compiler:2.28.3), jetified-dagger-spi-2.28.3 (com.google.dagger:dagger-spi:2.28.3) and jetified-hilt-android-compiler-2.28.3-alpha (com.google.dagger:hilt-android-compiler:2.28.3-alpha)```

【问题讨论】:

  • 没有你的 Gradle 文件是不清楚的。看起来你这里有一些重复的依赖项

标签: android kotlin dagger clean-architecture dagger-hilt


【解决方案1】:

我使用实现来添加依赖项而不是 kapt,在我更改之后,一切正常

【讨论】:

  • 因此,经过 4 小时找出各种解决方案后,这个可行!谢谢大佬!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-30
  • 2021-04-26
  • 2017-09-05
  • 2021-01-31
  • 2022-12-29
  • 2021-07-06
  • 2016-01-27
相关资源
最近更新 更多