Adyen / adyen-android

Adyen Android Drop-in and Components
https://docs.adyen.com/checkout/android
MIT License
126 stars 66 forks source link

Twint classname clash between Adyen & Datatrans prevents us to upgrade to v5.4+ #1701

Closed jschmid closed 1 week ago

jschmid commented 3 months ago

Describe the bug We are not able to upgrade to SDK v5.4+ because of a name clash with the Twint integration.

To Reproduce Include com.adyen.checkout:drop-in:5.6.0 and ch.datatrans:android-sdk:3.6.1 in the same project. Try to compile the project. You get an error:

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class a.a found in modules android-sdk-3.6.1.aar -> android-sdk-3.6.1-runtime (ch.datatrans:android-sdk:3.6.1) and twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0)
     Duplicate class a.b found in modules android-sdk-3.6.1.aar -> android-sdk-3.6.1-runtime (ch.datatrans:android-sdk:3.6.1) and twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0)
     Duplicate class ch.twint.payment.sdk.Twint found in modules twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0) and twint-sdk-android-7.0.0.aar -> twint-sdk-android-7.0.0-runtime (ch.twint.payment:twint-sdk-android:7.0.0)
     Duplicate class ch.twint.payment.sdk.TwintPayResult found in modules twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0) and twint-sdk-android-7.0.0.aar -> twint-sdk-android-7.0.0-runtime (ch.twint.payment:twint-sdk-android:7.0.0)
     Duplicate class ch.twint.payment.sdk.exceptions.TwintCodeEmptyOrBlankException found in modules twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0) and twint-sdk-android-7.0.0.aar -> twint-sdk-android-7.0.0-runtime (ch.twint.payment:twint-sdk-android:7.0.0)
     Duplicate class ch.twint.payment.sdk.exceptions.TwintException found in modules twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0) and twint-sdk-android-7.0.0.aar -> twint-sdk-android-7.0.0-runtime (ch.twint.payment:twint-sdk-android:7.0.0)
     Duplicate class ch.twint.payment.sdk.exceptions.TwintMethodCalledBeforeOnCreateException found in modules twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0) and twint-sdk-android-7.0.0.aar -> twint-sdk-android-7.0.0-runtime (ch.twint.payment:twint-sdk-android:7.0.0)
     Duplicate class ch.twint.payment.sdk.exceptions.TwintResultPendingException found in modules twint-5.6.0.aar -> twint-5.6.0-runtime (com.adyen.checkout:twint:5.6.0) and twint-sdk-android-7.0.0.aar -> twint-sdk-android-7.0.0-runtime (ch.twint.payment:twint-sdk-android:7.0.0)

Expected behavior

It is possible to include Adyen & Datatrans SDKs in the same project, and use Twint.

Additional context

I have a repro project that shows the issue: https://github.com/jschmid/AdyenDatatransClash This is the default Android Studio project, with only the dependencies added.

If you take commit https://github.com/jschmid/AdyenDatatransClash/commit/ae250c504d71f77f5cf7a1fa8c4fe5d1ba2b9473, you will see that it does not compile. A workaround is to exclude the Adyen Twint library: https://github.com/jschmid/AdyenDatatransClash/commit/29b908538fa1124d5fae8c7c27cb8bcbb8d98875

However this is only temporary for us as we want to use Twint on Adyen.

At first I thought that it could be linked to https://github.com/Adyen/adyen-android/issues/1666, but release 5.6.0 does not solve the issue for us.


I went down the rabbit hole and found this:

We kindly request that you find a way to not clash with Twint classes. If you are going to keep packaging the Twint SDK into your own SDK, one solution would be to repackage the Twint SDK under your own package, using Proguard repackageclasses.

jreij commented 3 months ago

Hi @jschmid, thanks for reaching out and for the detailed investigation. Unfortunately we do not have a solution for this on our side at the moment. repackageclasses will not work, since according to the documentation:

Counter-indication: classes that look for resource files in their package directories will no longer work properly if they are moved elsewhere. When in doubt, just leave the packaging untouched by not using this option.

EDIT: I actually think repackageclasses doesn't matter in this context because we are not the ones minifying the Twint SDK code, we receive an already packaged version.

We are working with Twint on resolving these issues, we hope that we will be able to provide a fix in the coming weeks. We will also contact you internally to provide more details and inform you about the progress.

In the meantime, please do reach out to Datatrans as well to make sure they are aware of the issue. Let me know if you have any more questions.

jschmid commented 3 months ago

Thank you for the swift reply @jreij.

I don't know if you have access to the Twint classes, or already a jar/aar. A solution would be to rename the package before compilation instead of using R8.

Similar report on Datatrans: https://github.com/datatrans/android-sdk/issues/25

jreij commented 3 months ago

@jschmid thanks for the suggestion. We receive a jar from Twint which is already minified so we simply include it in our own twint module and publish it.

jschmid commented 3 months ago

I'm going on vacation. Handing over the topic to my colleague @gtomek.

ozgur00 commented 4 days ago

Hi @jschmid, we have released 5.7.0 that resolves the issue.

jschmid commented 4 days ago

Thanks for the work! Now we wait for Datatrans to release their update, and we should be good!