添加依赖项时出现重复类错误|如何删除特定类别

时间:2020-09-17 12:14:21

标签: android gradle

我正在将对讲机依赖项添加到我的项目中

 implementation "io.intercom.android:intercom-sdk:8.+'"

我收到此错误:

Duplicate class okio.-Base64 found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-DeflaterSinkExtensions found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-DeprecatedOkio found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-DeprecatedUpgrade found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-DeprecatedUtf8 found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-GzipSinkExtensions found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-GzipSourceExtensions found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-InflaterSourceExtensions found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-Platform found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)
Duplicate class okio.-Util found in modules jetified-intercom-sdk-base-8.1.0-runtime.jar (io.intercom.android:intercom-sdk-base:8.1.0) and jetified-okio-jvm-2.4.3.jar (com.squareup.okio:okio:2.4.3)

我找不到添加到实现中的规则来排除此特定类okio.-Util等。有人可以帮忙吗?

谢谢

2 个答案:

答案 0 :(得分:1)

我知道这种将整个程序包从依赖项中排除的方法可能会对您有所帮助。

 // Retrofit
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation ("com.squareup.retrofit2:retrofit:$retrofitVersion") {
    exclude module: 'okhttp'
}

答案 1 :(得分:0)

我将发布答案,但这是针对该库的非常具体的内容,希望对任何人都可以有所帮助。

对讲机默认库在aar / jar中带有某些依赖项。为了避免这个问题,这里有一个没有它们的版本

https://www.intercom.com/help/en/articles/8716-using-transitive-dependencies-with-intercom-for-android

我最终添加了这个库,一切正常。