You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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)
The text was updated successfully, but these errors were encountered:
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
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
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
The defaultConfig values are,
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:
The text was updated successfully, but these errors were encountered: