powered by Jive Software

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

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

Would you propose to add

Security.addProvider(new BouncyCastleProvider());

to fix the issue?

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 {


dependencies {

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

compile ‘com.madgag.spongycastle:pkix:’


// 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