EDIT: Solution from Error: java.util.zip.ZipException: duplicate entry doesn't work here, because I don't have problem with support-v4 module
I'm trying to build an Android project which uses SpongyCastle, but unfortunately it requires javax.naming
package from jndi
library.
I added jndi and even javaEE to make it work, but gradle still has problem with running a project (build is successful)
My gradle.build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "grylls.cryptotexting"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'javax:javaee-api:7.0'
compile files('lib/jndi-1.2.1.jar')
}
Gradle throws this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:java.util.zip.ZipException:
duplicate entry:javax/mail/AuthenticationFailedException.class
When I tried to exclude javax.mail
from javax:javaee-api:7.0
I got:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException:
Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
Where can I find this duplication of javax.mail which by the way I don't even need?
To properly include SpongyCastle I had to make a change in dependencies :
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.madgag.spongycastle:pg:1.51.0.0'
}
Create a class that inserts BouncyCastle Provider
import android.app.Application;
import java.security.Security;
public class Dynks extends Application {
static { Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1); }
}
and include it in AndroidManifest.xml under "application" tag:
...
<application
android:name="Dynks"
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With