android java.lang.NoClassDefFoundError: org.bouncycastle.crypto.engines.AESEngine api 16 -


i using com.nimbusds.jose.crypto library in android client doing jwt stuff.

this declare in gradle file :

    compile 'com.nimbusds:nimbus-jose-jwt:4.23' 

everything works fine on api >=19, when running code on api 16, getting exception :

java.lang.noclassdeffounderror: org.bouncycastle.crypto.engines.aesengine.

what's issue here? why class aesengine not available on api 16?

if dependecy list of nimbus-jose-jwt there no bouncycastle library. however, if source code, , more precisely package com.nimbusds.jose.crypto.bc can see, uses bouncycastle without declaring dependency. library assumes bouncycastle present.

the solution add dependencies manually. first of all, follow link implement standard way of using bouncycastle on android.

however not solve problem, because org.bouncycastle.crypto.engines.aesengine not in 1 of libraries. solution add 1 more dependency:

dependencies { compile 'org.bouncycastle:bcprov-jdk15on:1.54' }

then should work fine.

summary:

gradle dependencies should lool like:

dependencies {     compile 'com.nimbusds:nimbus-jose-jwt:4.23'     compile 'com.madgag.spongycastle:core:1.54.0.0'     compile 'com.madgag.spongycastle:prov:1.54.0.0'     compile 'com.madgag.spongycastle:pkix:1.54.0.0'     compile 'com.madgag.spongycastle:pg:1.54.0.0'     compile 'org.bouncycastle:bcprov-jdk15on:1.54' } 

and should register java.security.provider:

static {     security.insertproviderat(new org.spongycastle.jce.provider.bouncycastleprovider(), 1); } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -