Proguard中的* vs ** vs ***?
Posted
技术标签:
【中文标题】Proguard中的* vs ** vs ***?【英文标题】:* vs ** vs *** in Proguard? 【发布时间】:2013-11-12 07:10:28 【问题描述】:Proguard 中的*
、**
和***
通配符有什么区别?例如:
-keep class com.mypackage.*
对
-keep class com.mypackage.**
对
-keep class com.mypackage.***
【问题讨论】:
【参考方案1】:* matches any part of a method name. OR 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).
注意*
和**
通配符永远不会匹配原始类型。此外,只有 * 通配符可以匹配任意维度的数组类型。例如,“ get*()”匹配"java.lang.Object getObject()"
,但不匹配"float getFloat()"
,也不匹配"java.lang.Object[] getObjects()"
。
【讨论】:
这个答案对应的文档在guardsquare.com/en/products/proguard/manual/…【参考方案2】:* matches any part of a filename not containing the directory separator.
** matches any part of a filename, possibly containing any number of directory separators.
【讨论】:
【参考方案3】:来自the document:
* matches any part of a class name not containing the package separator. For example, "com.example.*Test*" matches "com.example.Test" and "com.example.YourTestApplication", but not "com.example.mysubpackage.MyTest". Or, more generally, "com.example.*" matches all classes in "com.example", 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, "com.example.**" matches all classes in "com.example" and in its subpackages.
*** matches any type (primitive or non-primitive, array or non-array).
【讨论】:
以上是关于Proguard中的* vs ** vs ***?的主要内容,如果未能解决你的问题,请参考以下文章
ADT (Eclipse) vs. Android Studio:APK文件大小相差多少是正常的?
Android/Java 混淆:R8 与(ProGuard 或 DexGuard)?
Java世界中的类vs包vs模块vs组件vs容器vs服务vs平台[关闭]