当前位置: 代码迷 >> Android >> android 代码搅混
  详细解决方案

android 代码搅混

热度:89   发布时间:2016-05-01 14:04:55.0
android 代码混淆

android 代码混淆

1?proguard.cfg,这就是混淆所需的proguard脚本啊。

?

其代码如下:

?

?

view plain
  1. -optimizationpasses?5??
  2. -dontusemixedcaseclassnames??
  3. -dontskipnonpubliclibraryclasses??
  4. -dontpreverify??
  5. -verbose??
  6. -optimizations?!code/simplification/arithmetic,!field/*,!class/merging/*??
  7. -keep?public?class?*?extends?android.app.Activity??
  8. -keep?public?class?*?extends?android.app.Application??
  9. -keep?public?class?*?extends?android.app.Service??
  10. -keep?public?class?*?extends?android.content.BroadcastReceiver??
  11. -keep?public?class?*?extends?android.content.ContentProvider??
  12. -keep?public?class?com.android.vending.licensing.ILicensingService??
  13. -keepclasseswithmembernames?class?*?{??
  14. ????native?<methods>;??
  15. }??
  16. -keepclasseswithmembernames?class?*?{??
  17. ????public?<init>(android.content.Context,?android.util.AttributeSet);??
  18. }??
  19. -keepclasseswithmembernames?class?*?{??
  20. ????public?<init>(android.content.Context,?android.util.AttributeSet,?int);??
  21. }??
  22. -keepclassmembers?enum?*?{??
  23. ????public?static?**[]?values();??
  24. ????public?static?**?valueOf(java.lang.String);??
  25. }??
  26. -keep?class?*?implements?android.os.Parcelable?{??
  27. ??public?static?final?android.os.Parcelable$Creator?*;??
  28. }??

?

?

从脚本中可以看到,混淆中保留了继承自Activity、Service、Application、BroadcastReceiver、ContentProvider等基本组件。

并保留了所有的Native变量名及类名,所有类中部分以设定了固定参数格式的构造函数,枚举等等。(详细信息请参考<proguard_path>/examples中的例子及注释。)

2 在工程的"default.properties"中添加这样一句话“proguard.config=proguard.cfg”

?

?

打包签名后的.apk就是混淆的,其实我们只要做一步就可以了就是在"default.properties"中添加这样一句话“proguard.config=proguard.cfg”就可以了。

?

  相关解决方案