Lucas Moretto
Lucas Moretto

Reputation: 404

Duplicate class using product flavours

My android gradle build has many flavours. One of then has an aar file that contains a duplicate dependency (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
    }
    ...
}

This configuration produces the following for "standard" build (works for another flavours):

    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
    ...

I tried to change the config to:

    standardImplementation(name: 'libgedi-0.190121.gpos800', ext: 'aar') {
        configurations {
            all*.exclude group: 'com.google.zxing'
        }
    }

The config above works only when i'm build the "standard" flavour. To another flavors, this error occurs:

error: package com.google.zxing.qrcode.decoder does not exist

What i'm doing wrong?

Upvotes: 1

Views: 2602

Answers (1)

Lucas Moretto
Lucas Moretto

Reputation: 404

Solution:

{
    configurations {
        exclude group: 'com.google.zxing'
    }
}

use exclude instead all*exclude

Upvotes: 2

Related Questions