我正在努力让DexGuard在我正在开发的项目上运行。我已经使用proguard-rules.pro
成功运行了ProGuard。运行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
根据帖子Using Spongycastle with Proguard应该修复。
整个proguard-rules.pro可以在link to gist
找到答案 0 :(得分:6)
为了完整性&#39;清酒:我们通过电子邮件确定问题是由选项&#34; minifyEnabled true&#34;在build.gradle中,它与DexGuard插件不兼容。 DexGuard当然已经提供了缩小,优化和混淆。
(我是ProGuard和DexGuard的开发者)