Question

I am trying to make use of spongycastle and followed all the help I could get to include it but when the application execute it crashes at the code where I add it as a provider:

static {
    Security.addProvider(new org.spongycastle.jce.provider.BouncyCastleProvider());
}

I add scprov-jdk15-1.46.99.3-UNOFFICIAL-ROBERTO-RELEASE.jar as an external JAR to my project and eclipse does not report any errors.

Any ideas?

The stacktrace:

08-11 12:41:56.653: W/ActivityThread(683): Application com.ljbrits.test4 is waiting for the debugger on port 8100...
08-11 12:41:56.723: I/System.out(683): Sending WAIT chunk
08-11 12:41:56.723: I/dalvikvm(683): Debugger is active
08-11 12:41:56.914: I/System.out(683): Debugger has connected
08-11 12:41:56.914: I/System.out(683): waiting for debugger to settle...
08-11 12:41:57.113: I/System.out(683): waiting for debugger to settle...
08-11 12:41:57.153: I/dalvikvm(683): threadid=3: reacting to signal 3
08-11 12:41:57.203: I/dalvikvm(683): Wrote stack traces to '/data/anr/traces.txt'
:
08-11 12:41:59.344: I/System.out(683): waiting for debugger to settle...
08-11 12:41:59.546: I/System.out(683): debugger has settled (1437)
08-11 12:41:59.693: I/dalvikvm(683): threadid=3: reacting to signal 3
08-11 12:41:59.824: I/dalvikvm(683): Wrote stack traces to '/data/anr/traces.txt'
08-11 12:42:00.173: I/dalvikvm(683): threadid=3: reacting to signal 3
08-11 12:42:00.183: I/dalvikvm(683): Wrote stack traces to '/data/anr/traces.txt'
08-11 12:42:00.193: D/dalvikvm(683): threadid=1: still suspended after undo (sc=1 dc=1)
08-11 12:42:00.283: E/dalvikvm(683): Could not find class 'org.spongycastle.jce.provider.BouncyCastleProvider', referenced from method com.ljbrits.test4.Test4Activity.<clinit>
08-11 12:42:00.283: W/dalvikvm(683): VFY: unable to resolve new-instance 417 (Lorg/spongycastle/jce/provider/BouncyCastleProvider;) in Lcom/ljbrits/test4/Test4Activity;
08-11 12:42:00.283: D/dalvikvm(683): VFY: replacing opcode 0x22 at 0x0000
08-11 12:42:00.363: D/dalvikvm(683): DexOpt: unable to opt direct call 0x07d8 at 0x02 in Lcom/ljbrits/test4/Test4Activity;.<clinit>
08-11 12:42:00.683: I/dalvikvm(683): threadid=3: reacting to signal 3
08-11 12:42:00.714: D/dalvikvm(683): threadid=1: still suspended after undo (sc=1 dc=1)
08-11 12:42:00.714: I/dalvikvm(683): Wrote stack traces to '/data/anr/traces.txt'
:
08-11 12:42:06.233: I/dalvikvm(683): Wrote stack traces to '/data/anr/traces.txt'
08-11 12:42:08.719: W/dalvikvm(683): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/ljbrits/test4/Test4Activity;
08-11 12:42:08.719: W/dalvikvm(683): Class init failed in newInstance call (Lcom/ljbrits/test4/Test4Activity;)
Was it helpful?

Solution

The NoClassDefFoundError thrown here suggests that the SpongyCastle classes are not being included in your deployed apk file - try unzipping the apk to check this). This could be caused by a few things, make sure you do a clean build (are you builiding with ant or eclipse?) and if the problem persists, it's likely a proguard issue - ProGuard may be stripping out classes it thinks are unused - could you post your proguard.cfg?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top