We are using in our application stripe sdk version 16.1.1 and gradle can't build project due to duplicated class.
...
Duplicate class org.bouncycastle.x509.util.StreamParsingException found in modules jetified-bcprov-jdk15on-1.57 (org.bouncycastle:bcprov-jdk15on:1.57) and jetified-bcprov-jdk15to18-1.67 (org.bouncycastle:bcprov-jdk15to18:1.67)
...
It looks like a library has changed from bcprov-jdk15on-N.jar to bcprov-jdk15to18-N.jar since version 16.1.0 (bcprov-jdk15on is part of other library that used in our project and could not be removed or updated).
Do you have any solution, ideas, how to avoid current issue and use the latest stripe version.
https://www.bouncycastle.org/latest_releases.html
16.1.1
@lamrak thanks for filing this issue. I'll investigate and let you know what I find.
Could you provide more details about the other library? Was it compatible with bcprov-jdk15on?
Sure,
other library is the same on but with minor differences (described here https://www.bouncycastle.org/latest_releases.html):
bcprov-ext-jdk15on-167.jar
This version 15to18 comes In our project with the smack library.
You can try add this to catch this issue:
ext {
smackVersion = '4.3.4'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.igniterealtime.smack:smack-tcp:$smackVersion"
implementation "org.igniterealtime.smack:smack-android:$smackVersion"
implementation "org.igniterealtime.smack:smack-im:$smackVersion"
implementation "org.igniterealtime.smack:smack-extensions:$smackVersion"
implementation "org.igniterealtime.smack:smack-experimental:$smackVersion"
}
I see that in 16.0.0 you also have the same version of bcprov-jdk15on but starting from 16.1.0 (or 16.1.1) it was changed on bcprov-jdk15to18.
Hope it helps.
Can you try upgrading to stripe-android:16.2.0 and check if you are still experiencing this issue?
I see the same issue here
Duplicate class **** found in modules jetified-bcprov-jdk15on-1.57 (org.bouncycastle:bcprov-jdk15on:1.57) and jetified-bcprov-jdk15to18-1.68 (org.bouncycastle:bcprov-jdk15to18:1.68)
I need to check where it comes from but looks like the same
Here I created a default Android project and added smack and stripe dependencies. It's easy to see the same error:
@lamrak can you try using Gradle's DependencySubstitutions to replace the dependency?
Maybe something similar to what is suggested here? https://stackoverflow.com/a/48724412/11103900
I'll check.
In general I played with different solutions trying to exclude one of library and had no luck. But will check this one.
got it done,
with
configurations.all {
c -> c.resolutionStrategy.dependencySubstitution {
all { DependencySubstitution dependency ->
if (dependency.requested.group == 'org.bouncycastle') {
dependency.useTarget 'org.bouncycastle:bcprov-jdk15to18:1.68'
}
}
}
}
project is built and run successfully. Hope everything will work now,
Thank you!
Just need to add comment that for my multi modules project it works on slightly another way
configurations.all {
c -> c.resolutionStrategy.eachDependency {
DependencyResolveDetails dependency ->
println dependency.requested.group
if (dependency.requested.group == 'org.bouncycastle') {
dependency.useTarget 'org.bouncycastle:bcprov-jdk15to18:1.68'
}
}
}
@lamrak that is fantastic to hear, thanks for sharing what worked for you. I'll add a link to your setup in the comments.
Just need to add comment that for my multi modules project it works on slightly another way
configurations.all { c -> c.resolutionStrategy.eachDependency { DependencyResolveDetails dependency -> println dependency.requested.group if (dependency.requested.group == 'org.bouncycastle') { dependency.useTarget 'org.bouncycastle:bcprov-jdk15to18:1.68' } } }
This worked for me, I have no idea how but it did... this was the error I was getting more specifically.
Duplicate class org.bouncycastle.x509.util.StreamParsingException found in modules jetified-bcprov-jdk15on-1.65.jar
(org.bouncycastle:bcprov-jdk15on:1.65) and jetified-bcprov-jdk15to18-1.68.jar (org.bouncycastle:bcprov-jdk15to18:1.68)What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
More than one file was found with OS independent path >org/bouncycastle/x509/CertPathReviewerMessages_de.properties.