androidkotlinsecurityduplicatestink

Getting duplicate class error for tink-android module


In my project, I am using androidx.security:security-crypto-ktx library for EncryptedSharedPreference. Now I have to use com.google.crypto.tink:apps-paymentmethodtoken library.

When I am trying to use these both together, I am getting this error for all the files inside tink-android module.

Caused by: java.lang.RuntimeException: Duplicate class com.google.crypto.tink.AccessesPartialKey found in modules jetified-tink-1.8.0 (com.google.crypto.tink:tink:1.8.0) and jetified-tink-android-1.8.0 (com.google.crypto.tink:tink-android:1.8.0)

I have tried updating both the libraries to their latest version but the issue still persists. I have also tried excluding the module from the library like this

exclude(group = "com.google.crypto.tink", module = "tink-android")

but when I do this with androidx-security library then I get class not found exception with EncryptedSharedPreference's file.

Has anyone else faced similar issue like this? Or any idea how can I resolve this?


Solution

  • Try using exclude(group = "com.google.crypto.tink", module = "tink")