Android build.gradle 排除重复项 类

Android build.gradle Exclude duplicate classes

在这个项目中,我需要集成两个库Bitmovin and Purchasely。添加这两个依赖项后,由于 bitmovin 和 puchasely 库之间存在冲突,应用程序无法 运行。我知道有一种方法可以通过排除所有重复的 类 来解决这个问题。不幸的是,我不熟悉这个术语,无法弄清楚要排除的组名和模块名是什么。另外,我不确定我应该使用哪个依赖项来“排除”。

implementation ("com.bitmovin.player:playercore:2.64.0"){
   exclude group: 'group_name', module: 'module_name'
}
implementation ("io.purchasely:core:2.4.5"){
   exclude group: 'group_name', module: 'module_name'
}

如果我成功删除重复项 类,是否会导致任何一个库在 运行 时停止工作或中断?

构建失败日志

这些应该是重复的 类

您可以通过命令

找到您项目的所有依赖项

./gradlew :app:dependencies

Bitmovin 和 Purchasely 好像都用 exoplayer。 因此,为避免冲突,您可以从这些依赖项之一中删除模块 exoplayer。

对于您的情况,我认为您应该将其从 Purchasely 中删除

implementation ("io.purchasely:core:2.4.7") {
    exclude module: 'exoplayer-core'
    exclude module: 'exoplayer-hls'
    exclude module: 'exoplayer-dash'
    exclude module: 'exoplayer-ui'
    exclude module: 'extension-okhttp'
    exclude module: 'extension-mediasession'
}