我很难找到基于他们注释的东西(在Android下).
我有一个注释,com.example.Keep:
@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
public @interface Keep {
}
Run Code Online (Sandbox Code Playgroud)
我有一个类,它只是通过反射构建的:
public class Bar extends Foo {
@com.example.Keep
Bar(String a, String b) { super(a, b); }
//...
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作(类保持其构造函数,虽然有一个模糊的类名)当我的proguard配置包括以下内容:
-keepattributes Signature,*Annotation*,SourceFile,LineNumberTable
-keepclassmembers class ** extends com.example.Bar {
<init>(...);
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试将其更改为:它会删除构造函数:
-keepattributes Signature,*Annotation*,SourceFile,LineNumberTable
-keepclassmembers class ** extends com.example.Bar {
@com.example.Keep <init>(...);
}
Run Code Online (Sandbox Code Playgroud)
我用自己的注释和proguard的annotation.jar注释看到了相同的行为.我已经复制并粘贴了Foo导入的注释名称Keep,所以我相信它不是拼写错误或导入错误.
谁能想到我可能会失踪的东西?