Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Duplicate class org.tensorflow.lite #8166

Open
VinuPolly-Bonnet opened this issue Mar 27, 2024 · 2 comments
Open

[BUG] Duplicate class org.tensorflow.lite #8166

VinuPolly-Bonnet opened this issue Mar 27, 2024 · 2 comments
Assignees
Labels

Comments

@VinuPolly-Bonnet
Copy link

Summary

When trying to include the Tensorflow lite library in the gradle, the build process fails with duplicate classes issue. This is observed if the we include the stripe card scan library for the scanning functionality within Stripe.

Code to reproduce

Add the following in the app level gradle and try to build the app

/* Stripe */
implementation 'com.stripe:stripe-android:20.39.0'
implementation 'com.stripe:stripecardscan:20.39.0'
implementation 'org.tensorflow:tensorflow-lite:2.15.0'

The defaultConfig values are,

defaultConfig {
        //.....
        minSdkVersion 26
        targetSdkVersion 34
        compileSdk 34
        //....
    }

Impacted devices

Couldn't get successful build

Installation method

gradle dependency

Dependency Versions

kotlin: 1.9.0
stripe-android: 20.39.0
Android Gradle Plugin: 8.3.0
Gradle: gradle-8.4-bin.zip

Other information

Build error log:

Duplicate class org.tensorflow.lite.DataType found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.DataType$1 found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.Delegate found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.Interpreter found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-2.15.0-runtime (org.tensorflow:tensorflow-lite:2.15.0)
Duplicate class org.tensorflow.lite.Interpreter$Options found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-2.15.0-runtime (org.tensorflow:tensorflow-lite:2.15.0)
Duplicate class org.tensorflow.lite.NativeInterpreterWrapper found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-2.15.0-runtime (org.tensorflow:tensorflow-lite:2.15.0)
Duplicate class org.tensorflow.lite.Tensor found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.Tensor$QuantizationParams found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.TensorFlowLite found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.annotations.UsedByReflection found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.nnapi.NnApiDelegate found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)
Duplicate class org.tensorflow.lite.nnapi.NnApiDelegate$Options found in modules jetified-stripecardscan-tflite-20.39.0-runtime (com.stripe:stripecardscan-tflite:20.39.0) and jetified-tensorflow-lite-api-2.15.0-runtime (org.tensorflow:tensorflow-lite-api:2.15.0)


@VinuPolly-Bonnet
Copy link
Author

Hi @jaynewstrom-stripe @ccen-stripe just checking in, is there any workaround for this problem? Need to use tflite in our project for a new requirement.
Thanks

@ccen-stripe
Copy link
Collaborator

hi @VinuPolly-Bonnet cardscan uses an different internal tensorlow dep, causing a conflict of classes, to use it with the default tflite runtime, please update the corresponding stripe related tflite modules as follows -

implementation('com.stripe:stripe-android:20.40.4')
implementation('com.stripe:stripecardscan:20.40.4') {
    exclude group: 'com.stripe', module: 'ml-core-cardscan' // exclude the cardscan-specific portable tflite runtime
}

implementation('com.stripe:ml-core-default:20.40.4') // include ml-core-default, which has org.tensorflow:tensorflow-lite

// no need to declare org.tensorflow:tensorflow-lite explicitly

With this change you'll be able to use cardscan and org.tensorflow.lite.Interpreter in the app.

Please note we're currently still using 2.11.0 for org.tensorflow:tensorflow-lite, will update this to 2.15.0 in the upcoming release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants