kri*_*aex 7 java annotations interface proguard
我想用自定义@Keep注释在我的应用程序中注释一些接口,并配置ProGuard
我试过类似的东西
# Kept interfaces and all their methods
-keep interface @com.foo.bar.annotation.Keep * {
<methods>;
}
# Classes implementing kept interfaces
-keep class * implements @com.foo.bar.annotation.Keep *
Run Code Online (Sandbox Code Playgroud)
但显然语法无效.我尝试了其他的东西,但是ProGuard文档及其示例并没有真正清楚确切的语法以及在什么情况下可能出现的情况.
很抱歉回答我自己的问题,但我碰巧碰到了解决方案.实际上它比我想象的要简单得多:
# Annotated interfaces (including methods which are also kept in implementing classes)
-keep @com.foo.bar.annotation.Keep interface * {
*;
}
Run Code Online (Sandbox Code Playgroud)
显然,<methods>在接口keep子句上指定是错误的,可能是因为ProGuard只过滤实际的方法实现,而不仅仅是在接口声明中可以找到的方法声明.
上面的语法似乎保留了完整的接口(类名,方法名)以及所有实现方法名,如果我考虑它,这是合乎逻辑的,因为如果我实现了接口,我无论如何都不能改变(混淆)方法名.
| 归档时间: |
|
| 查看次数: |
5203 次 |
| 最近记录: |