Java.util.zip.ZipException with spongycastle LICENSE.class

I am trying to include two different third-party libraries that seem to include different versions of Spongy castle. Both are enabled through compilation commands in my build.gradle, and one of them is enabled as AAR ( @aar ), and the other is enabled as usual.

When I try to compile debug buildType with these two libs (synchronization does not show the problem). I see the following:

Error: execution completed for task ': Application: transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org /spongycastle/LICENSE.class

Look around for how to solve this problem, preserving both libraries (as needed), but could not find a way to do this. Any help from an advanced Android developer or gradle expert would be greatly appreciated.

Thanks!

[build.gradle]

 apply plugin: 'com.android.application' repositories { maven { url 'http://mobile-sdk.jumio.com' } } android { compileSdkVersion 23 buildToolsVersion "23.0.2" packagingOptions { pickFirst 'org/spongycastle/x509/CertPathReviewerMessages.properties' pickFirst 'org/spongycastle/x509/CertPathReviewerMessages_de.properties' } defaultConfig { applicationId "com.example.me.license" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' compile "com.jumio.android:jumio-mobile-sdk: 1.9.0@aar " compile 'com.worldpay:cse-android-sdk:1.0.2' } 
+5
source share
1 answer

This is what happens if developers directly relate their dependencies. The bad guy here is jumio-mobile-sdk . This package includes the com.madgag.spongycastle classes directly, instead of specifying them in pom as it should be done.

Fortunately for you, the other package is configured correctly, so you can exclude spongycastle from it:

 compile ('com.worldpay:cse-android-sdk:1.0.2'){ exclude group: 'com.madgag.spongycastle' } 

Now imagine that both packages would include classes directly. Then there would be no other way to manually edit the files. That's why I hate it if someone does what the guys from Jumio do. If you have contacts, tell them to prepare their package for dependency systems, so this problem will not occur again.

+3
source

All Articles