android 混淆 配置

如果android应用中使用了反射功能,比如JSON的序列化和反序列化,要求某些实体类的字段和方法保持不变,设置方法为

-keep public class * implements android.os.Parcelable{ 

    public protected private *;

} 这里    public protected private *就是匹配该类的任一方法和字段。

下边是摘录的ProGuard常用匹配选项,参考:http://proguard.sourceforge.net/index.html#manual/usage.html。

  • The class keyword refers to any interface or class. The interface keyword restricts matches to interface classes. The enum keyword restricts matches to enumeration classes. Preceding the interface or enum keywords by a ! restricts matches to classes that are not interfaces or enumerations, respectively.
  • Every classname must be fully qualified, e.g. java.lang.String. Class names may be specified as regular expressions containing the following wildcards:
  • ?matches any single character in a class name, but not the package separator. For example, "mypackage.Test?" matches "mypackage.Test1" and "mypackage.Test2", but not "mypackage.Test12".
    *matches any part of a class name not containing the package separator. For example, "mypackage.*Test*" matches "mypackage.Test" and "mypackage.YourTestApplication", but not "mypackage.mysubpackage.MyTest". Or, more generally, "mypackage.*" matches all classes in "mypackage", but not in its subpackages.
    **matches any part of a class name, possibly containing any number of package separators. For example, "**.Test" matches all Test classes in all packages except the root package. Or, "mypackage.**" matches all classes in "mypackage" and in its subpackages.
  • For additional flexibility, class names can actually be comma-separated lists of class names, with optional ! negators, just like file name filters. This notation doesn't look very Java-like, so it should be used with moderation.
  • The extends and implements specifications are typically used to restrict classes with wildcards. They are currently equivalent, specifying that only classes extending or implementing the given class qualify. Note that the given class itself is not included in this set. If required, it should be specified in a separate option.
  • The @ specifications can be used to restrict classes and class members to the ones that are annotated with the specified annotation types. An annotationtype is specified just like a classname.
  • Fields and methods are specified much like in Java, except that method argument lists don't contain argument names (just like in other tools like javadoc and javap). The specifications can also contain the following catch-all wildcards:
  • <init>matches any constructor.
    <fields>matches any field.
    <methods>matches any method.
    *matches any field or method.
  • Note that the above wildcards don't have return types. Only the <init> wildcard has an argument list.
    ?matches any single character in a method name.
    *matches any part of a method name.
    Types in descriptors can contain the following wildcards:

  • For convenience and for backward compatibility, the class name * refers to any class, irrespective of its package.

  • Fields and methods may also be specified using regular expressions. Names can contain the following wildcards:

    %matches any primitive type ("boolean", "int", etc, but not "void").
    ?matches any single character in a class name.
    *matches any part of a class name not containing the package separator.
    **matches any part of a class name, possibly containing any number of package separators.
    ***matches any type (primitive or non-primitive, array or non-array).
    ...matches any number of arguments of any type.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值