Monday, February 13, 2012

Android导入第三方jar包,proguard混淆脚本(屏蔽警告,不混淆第三方包)


最近1个项目中 需要导入移动MM的第三方计费包,混淆时用到了如下脚本,可屏蔽警告,不混淆第三方包指定内容。
非常有效

proguard.cfg 文件

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-ignorewarnings //这1句是屏蔽警告,脚本中把这行注释去掉
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
//这1句是导入第三方的类库,防止混淆时候读取包内容出错,脚本中把这行注释去掉
-libraryjars libs/mmbilling.jar
-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 ;
}
-keepclasseswithmembernames class * {
    public (android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
    public (android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

//这4句是不混淆第三方包中的指定内容,脚本中把这行注释去掉
-keep class com.ccit.** {*; }  
-keep class ccit.** { *; }
-keep class com.aspire.**
-keep class mm.vending.**


Error Message:  '-jar' is not recognized as an internal or external command, 
Solution: set up the "PROGUARD_HOME" EVN PATH to \tools\proguard 2, restart eclipse 3, now it work fine!

No comments:

Post a Comment