3

我正在尝试让 DexGuard 在我正在处理的项目上运行。我已经让 ProGuard 成功运行proguard-rules.pro。运行 DexGuard 版本构建后,应用程序崩溃

FATAL EXCEPTION: main
Process: com.project.fr, PID: 7937
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/spongycastle/jce/provider/BouncyCastleProvider;
    at com.project.CustomApplication.<clinit>(:44)
    at java.lang.reflect.Constructor.newInstance(Native Method)
    at java.lang.Class.newInstance(Class.java:1572)
    at android.app.Instrumentation.newApplication(Instrumentation.java:994)
    at android.app.Instrumentation.newApplication(Instrumentation.java:979)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:558)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491)
    at android.app.ActivityThread.access$1500(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.spongycastle.jce.provider.BouncyCastleProvider" on path: DexPathList[[zip file "/data/app/com.project.fr-1/base.apk"],nativeLibraryDirectories=[/data/app/com.project.fr-1/lib/arm, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 16 more
    Suppressed: java.lang.ClassNotFoundException: org.spongycastle.jce.provider.BouncyCastleProvider
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 17 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

当我使用 proguard 构建应用程序时,proguard-rules.pro它运行良好。

在 rules.pro 我启用了这个选项。

## Spongycastle
-keep class org.spongycastle.**
-dontwarn org.spongycastle.jce.provider.X509LDAPCertStoreSpi
-dontwarn org.spongycastle.x509.util.LDAPStoreHelper

根据 Post Using Spongycastle with Proguard应该是修复。

整个 proguard-rules.pro 可以在这里找到链接到 gist

4

1 回答 1

7

为了完整起见:我们已经通过电子邮件确定问题是由 build.gradle 中的选项“minifyEnabled true”引起的,该选项与 DexGuard 插件不兼容。DexGuard 当然已经提供了收缩、优化和混淆功能。

(我是 ProGuard 和 DexGuard 的开发者)

于 2014-12-15T23:14:59.247 回答