Using Spongycastle with Proguard

安稳与你 提交于 2019-12-22 10:39:00

问题


I've been strugling with proguard to make Spongycastle work. Most of the time, the problem comes when I'm exporting a signed APK, either I've got error, or the app will just crash before starting.

So, I've managed to gather informations to get a working proguard configuration :

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-repackageclasses ''
-allowaccessmodification
-keepattributes *Annotation*

-optimizations !code/simplification/arithmetic

-libraryjars C:\Program Files\Java\jre7\lib\rt.jar
-libraryjars libs\sc-light-jdk15on-1.47.0.2.jar
-libraryjars libs\scprov-jdk15on-1.47.0.2.jar

-injars libs

-outjars bin/classes-processed.jar

-dontwarn javax.naming.**
-dontwarn android.support.**


####
-keep class org.**  { *; }

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

I'm running ADT Version: 22.0.0.v201305140200--675183 The test phone is under Android 2.3.5

The part that borrows me is the "-keep class org.** { *; }" .... Am I doing it right ? I've tried "-keep class org.spongycastle.** { *; }", but the app just crash before startup...

Thanks !


回答1:


We added

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

But we now run into the problem that we hit the DEX method limit of 2^16 with that lib. We only need it for the MD5 and SHA-1 algorithms as some phones don't ship those.



来源:https://stackoverflow.com/questions/16603421/using-spongycastle-with-proguard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!