简体   繁体   English

使用Spongycastle和Proguard

[英]Using Spongycastle with Proguard

I've been strugling with proguard to make Spongycastle work. 我一直在与proguard打成一片,让Spongycastle工作。 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. 大多数时候,问题出现在我导出已签名的APK时,要么我有错误,要么应用程序在启动之前就会崩溃。

So, I've managed to gather informations to get a working proguard configuration : 所以,我设法收集信息以获得有效的proguard配置:

-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 我正在运行ADT版本:22.0.0.v201305140200--675183测试手机在Android 2.3.5下

The part that borrows me is the " -keep class org.** { *; } " .... Am I doing it right ? 借给我的部分是“ -keep class org.** { *; } ”....我做得对吗? I've tried " -keep class org.spongycastle.** { *; } ", but the app just crash before startup... 我试过“ -keep class org.spongycastle.** { *; } ”,但应用程序在启动之前就崩溃了......

Thanks ! 谢谢 !

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. 但是我们现在遇到的问题是我们使用该lib达到了DEX方法限制2 ^ 16。 We only need it for the MD5 and SHA-1 algorithms as some phones don't ship those. 我们只需要它用于MD5和SHA-1算法,因为有些手机不提供这些算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM