无法在Android中添加Spongycastle作为提供程序

时间:2012-08-09 11:27:07

标签: android security spongycastle

我正在尝试使用spongycastle并遵循所有help我可以包含它但是当应用程序执行时它会崩溃在我将其添加为提供程序的代码中:

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

我将scprov-jdk15-1.46.99.3-UNOFFICIAL-ROBERTO-RELEASE.jar作为外部JAR添加到我的项目中,eclipse不会报告任何错误。

有什么想法吗?

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;)

1 个答案:

答案 0 :(得分:0)

这里抛出的NoClassDefFoundError表明SpongyCastle类没有包含在你部署的apk文件中 - 尝试解压缩apk来检查这个)。这可能是由一些事情引起的,确保你做了一个干净的构建(你是用蚂蚁还是eclipse建立?)如果问题仍然存在,那很可能是一个问题 - ProGuard可能正在剥离它认为未使用的类 - 可能你发布你的proguard.cfg?