使用产品口味重复 class
Duplicate class using product flavours
我的 android gradle 版本有很多种。
其中之一有一个包含重复依赖项的 aar 文件 (com.google.zxing)。
build.gradle:
...
dependencies {
implementation 'com.google.zxing:core:3.3.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
// Standard flavour
standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
exclude group: 'com.google.zxing', module: 'android-core'
transitive = false
}
...
}
此配置为 "standard" 构建生成以下内容(适用于其他风格):
Duplicate class com.google.zxing.BarcodeFormat found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.Binarizer found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.BinaryBitmap found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.ChecksumException found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos8
...
我尝试将配置更改为:
standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
configurations {
all*.exclude group: 'com.google.zxing'
}
}
上面的配置仅在我构建 "standard" 风格时有效。换个口味,出现这个错误:
error: package com.google.zxing.qrcode.decoder does not exist
我做错了什么?
解决方案:
{
configurations {
exclude group: 'com.google.zxing'
}
}
使用排除而不是全部*排除
我的 android gradle 版本有很多种。 其中之一有一个包含重复依赖项的 aar 文件 (com.google.zxing)。
build.gradle:
...
dependencies {
implementation 'com.google.zxing:core:3.3.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
// Standard flavour
standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
exclude group: 'com.google.zxing', module: 'android-core'
transitive = false
}
...
}
此配置为 "standard" 构建生成以下内容(适用于其他风格):
Duplicate class com.google.zxing.BarcodeFormat found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.Binarizer found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.BinaryBitmap found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos800:)
Duplicate class com.google.zxing.ChecksumException found in modules core-3.3.3.jar (com.google.zxing:core:3.3.3) and zxing-2.1.jar (:libgedi-0.190121.gpos8
...
我尝试将配置更改为:
standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
configurations {
all*.exclude group: 'com.google.zxing'
}
}
上面的配置仅在我构建 "standard" 风格时有效。换个口味,出现这个错误:
error: package com.google.zxing.qrcode.decoder does not exist
我做错了什么?
解决方案:
{
configurations {
exclude group: 'com.google.zxing'
}
}
使用排除而不是全部*排除