1

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;)
Community
  • 1
  • 1
LJB
  • 47
  • 9
  • I've also tried this with the latest Bouncycastle JAR which fails with the same crash. – LJB Aug 11 '12 at 08:06
  • I am targeting Android 4.0 and above – LJB Aug 11 '12 at 08:07
  • Could you include the stacktrace of the error?you should be able to find this using 'adb logcat' – Roberto Tyley Aug 11 '12 at 08:20
  • Added the stacktrace. I am using the simulator and copied this logcat output via the logcat-tab in eclipse. Correct me if I am wrong but I assume this is the same output as from adb logcat. – LJB Aug 11 '12 at 12:49

1 Answers1

0

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?

Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101
  • I am using Eclipse, so from the Project-menu I cleaned the project and build it again. Looking at the apk file created in the bin directory of my project directory, I can see a res, assets and META-INF directory as well as the resources.arsc, classes.dex and AndroidManifest.xml files. The proguard stuff is still commented out in the project.properties file. Is this the correct place to verify it is disabled? – LJB Aug 11 '12 at 15:18
  • 1
    Seem so work now: I found some help with eclipse which state that one must mark libraries which must be part of the APK as exported (last tab on properties dialog in eclipse). I did so and now the crash is gone. Thanks for putting me on the right course of thinking with your reply. – LJB Aug 11 '12 at 15:37
  • I found the same isseue. However, in my case when jar file is exported with the apk, it runs into GC Overhead Limit fail... Any Idea what I may be doing wrong? – Prashant Gami Oct 15 '12 at 03:21