Android源码混淆脚本proguard
2013-10-24 11:32 默契. 阅读(397) 评论(0) 编辑 收藏 举报怎么用?
1,工程根目录下创建一个文件proguard.cfg;(名字随便起)
2,在project.properties末尾添加一行proguard.config=proguard.cfg
怎么写?
先来个现成的:
#优化级别 -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses #不预审核 -dontpreverify #屏蔽警告信息 -ignorewarnings -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* #导入第三方的类库,防止混淆时候读取包内容出错 -libraryjars libs/universal-image-loader-1.8.7-snapshot-with-sources.jar -libraryjars libs/android-support-v4.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 <methods>; } #枚举什么的 -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } #保护有指定标签的成员 -keepclassmembers class * { @cn.moqi.general.widget.util.annotation.* <methods>; @cn.moqi.general.widget.util.annotation.* <fields>; }