首页 > 解决方案 > Android Gradle依赖重复类错误

问题描述

将 Square 的 Reader SDK 安装到我的应用程序后,我在一些 Gradle 依赖项之间遇到了重复的类错误,如下所示。

dependencies {
  def readerSdkVersion = "1.3.5"
  implementation "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APPLICATION_ID:$readerSdkVersion"
  runtimeOnly ("com.squareup.sdk.reader:reader-sdk-internals:$readerSdkVersion") {
    exclude group: 'com.squareup.phrase', module: 'phrase'
  }
  implementation 'com.squareup.phrase:phrase:1.1.0'

  implementation 'androidx.appcompat:appcompat:1.0.2'
  implementation 'androidx.multidex:multidex:2.0.1'
}
Duplicate class com.squareup.phrase.BuildConfig found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.ListPhrase found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.ListPhrase$1 found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.ListPhrase$Formatter found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$KeyToken found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$LeftCurlyBracketToken found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$TextToken found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)
Duplicate class com.squareup.phrase.Phrase$Token found in modules jetified-phrase-1.1.0.jar (com.squareup.phrase:phrase:1.1.0) and reader-sdk-internals-1.3.5.jar (com.squareup.sdk.reader:reader-sdk-internals:1.3.5)

我在这里错过了什么吗?是的,我拥有前面提到的 SDK 文档中提到的所有其他 Gradle 配置(即 multidex 和编译选项集)。

标签: androidgradleandroid-gradle-plugindependenciestransitive-dependency

解决方案


推荐阅读