powered by Jive Software

Smack source compile for android API level 8 will crash with android internal bouncycastle libraries


#1

While doing smack library source compilation, found that it provides support for Android API level 8. However Omemo library uses bouncycastle library.

Any use of bouncycastle for android will clash with the android internal bouncycastle library for api level below 11.

Please refer to the site for more information.

Spongy Castle: is it obsolete? · Issue #34 · rtyley/spongycastle · GitHub


#2

Would you propose to add

Security.removeProvider("BC");
Security.addProvider(new BouncyCastleProvider());

to fix the issue?


#3

I do not think you can remove android inherited “BC” and replaced with new. I might be wrong.

I am not sure what is the best solution.

One simple solution is to change smack minimum SDK support to 11 in version.gradle i.e.

allprojects {

ext {

shortVersion = ‘4.2.1-beta2’

isSnapshot = true

jxmppVersion = ‘0.5.0’

smackMinAndroidSdk = 11

}

}

Alternative user who wish to use smack for android API level less than 11 need to do the following e.g.

configurations {

jarjar2
}

dependencies {

jarjar2 ‘com.googlecode.jarjar:jarjar:1.3’

compile ‘com.madgag.spongycastle:pkix:1.54.0.0’

}

// renames packages to avoid conflict with android internal libraries
task jarRepackage(type: Copy, description: ‘Repackage jar to avoid conflict’) {
project.ant {
taskdef name: “jarjar2”, classname: ‘com.tonicsystems.jarjar.JarJarTask’,

classpath: configurations.jarjar2.asPath

jarjar2(jarfile: ‘libs/smack-omemo.jar’) {
zipfileset(src: ‘lib/smack/smack-omemo.jar’)
rule pattern: ‘org.bouncycastle.**’,

result: ‘org.spongycastle.@1
}
}
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn jarRepackage

}