Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Getting duplicated class errors, how to avoid it? #64

Closed
joao-gabriel-gois opened this issue Aug 4, 2020 · 5 comments
Closed

Getting duplicated class errors, how to avoid it? #64

joao-gabriel-gois opened this issue Aug 4, 2020 · 5 comments

Comments

@joao-gabriel-gois
Copy link

By troubleshooting session of ReadMe, I saw this:

Unfortunately jetifier can't solve all your problems. Here are some reasons it could fail:

  1. You have a dependency that packages things in violation of Android packaging rules, like including an extra AndroidManifest.xml or similar: fix: bottomsheet-1.3.1.aar incorrectly includes aapt/AndroidManifest.xml Clip-sub/react-native-bottomsheet#23 - this will lead to dex merger issues about duplicate entries. Open pull requests with the libraries that do this.

I have one customer project (React Native v0.59.9) that depends on jetify to work but has one node_module that has its own AndroidManifest.xml file. There is any way to run jetify without affect only this module? Any flag / config that may ignore the process to one particular module?

It would be good to have more control of where and how jetify runs in the whole project. Already tried on gradle level (things such as blacklist) and we still getting the same error:

Duplicate class org.spongycastle.util.encoders.Base64 found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.encoders.Base64Encoder found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.encoders.Encoder found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.io.pem.PemGenerationException found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.io.pem.PemHeader found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.io.pem.PemObject found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.io.pem.PemObjectGenerator found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.io.pem.PemReader found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)
Duplicate class org.spongycastle.util.io.pem.PemWriter found in modules core-1.51.0.0.jar (com.madgag.spongycastle:core:1.51.0.0) and jetified-vpnsdk-3.6.8-runtime.jar (com.datami:vpnsdk:3.6.8)

Go to the documentation to learn how to Fix dependency resolution errors.
@mikehardy
Copy link
Owner

Unfortunately no. I think there's a pull request open for controlling but it hasn't been necessary and I'd strongly prefer not to as it hasn't been necessary for a year. The right course of action is to fix the module. The second-most-right course of action is to use https://github.com/ds300/patch-package to fix it in exactly the way I PRd to the linked example

@joao-gabriel-gois
Copy link
Author

Ok, thanks for informing. I guess upgrade to react native 61.5 is the only workaround available for us for now, since it will not need jetifier as per NPM description. Without AndroidManifest this module breaks and patch-package didn't worked at all.

Thanks for the fast response, anyway. :)

@mikehardy
Copy link
Owner

upgrading will likely get rid of the problem just because most modules are AndroidX now so you won't need to reverse jetify. I am sorry in advance for you as that is a difficult upgrade, but https://react-native-community.github.io/upgrade-helper/ can help, and the end result (if you haven't worked with 0.60+ yet) is very very, nice. Auto-linking is a really big improvement. Fast reload is fantastic, etc.

@joao-gabriel-gois
Copy link
Author

joao-gabriel-gois commented Aug 5, 2020

Thanks for support. It may help. So we only got this because client was running manually, and in this case it was applying for all node_modules, right? In 61.5 I could see as per NPM Description that is not required to run manually. Closed this ticket. Comment here if it actually works, after upgrading, for reference.

Thanks!

@mikehardy
Copy link
Owner

jetifier always runs against all of node_modules if you run it, and for the react-native-cli bundled with react-native it runs automatically by default (against all node_modules).

It basically always runs, and if it fails, the module it fails on needs a change - we haven't documented a failure in months and months even against failing modules, and prior to that it was always something the module was doing ... not quite right and they were always willing to patch the module, with patch-package working until then. No idea what module you're having a problem with but you should really pursue it with them

That said, upgrading to current stable react-native (0.62.2 now) is generally recommended

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

No branches or pull requests

2 participants