Java 如何防止覆盖\实现另一个方法的类方法名称被混淆?
如果我有一个实现接口a的Java 如何防止覆盖\实现另一个方法的类方法名称被混淆?,java,android,proguard,Java,Android,Proguard,如果我有一个实现接口a的类B,而Proguard不知道该接口的存在,我如何保留实现接口a的抽象方法的方法的名称 请注意,我希望保留方法名称,但我确实希望它们的内容被混淆 更新: 这就是我所拥有的(请注意评论): 我想为这种情况提供一个通用的解决方案——我不想在ProGuard配置中说明接口名称。我已经写了一篇博客,为Android应用程序编程。请查看下面的链接 ProGuard可以做你描述的事情。如果不希望重命名类和方法,请尝试以下方法: -keep,allowshrinking,allowo
类B
,而Proguard不知道该接口的存在,我如何保留实现接口a的抽象方法的方法的名称
请注意,我希望保留方法名称,但我确实希望它们的内容被混淆
更新:
这就是我所拥有的(请注意评论):
我想为这种情况提供一个通用的解决方案——我不想在ProGuard配置中说明接口名称。我已经写了一篇博客,为Android应用程序编程。请查看下面的链接 ProGuard可以做你描述的事情。如果不希望重命名类和方法,请尝试以下方法:
-keep,allowshrinking,allowoptimization class * { <methods>; }
-保留、允许收缩、允许优化类*{;}
希望这有帮助
#Keeping all public class names and keep (prevent obfuscation) of their public and protected methods
-keep public class * {
public protected <methods>;
}
# Keep (prevent obfuscation) all public and protected methods in non-public classes.
# Notice that the non-public class names will still get obfuscated
-keepclassmembers !public class * {
public protected <methods>;
}
# Don't keep the local variables attributes (LocalVariableTable and LocalVariableTypeTable are dropped).
-keepattributes Exceptions,Signature,Deprecated,SourceFile,SourceDir,LineNumberTable,Synthetic,EnclosingMethod,RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations,AnnotationDefault,InnerClasses,*Annotation*
#保留所有公共类名并保留(防止混淆)其公共和受保护的方法
-保持公开课*{
受公众保护;
}
#在非公共类中保留(防止混淆)所有公共和受保护的方法。
#请注意,非公共类名仍然会被混淆
-不准入内!公共课*{
受公众保护;
}
#不要保留LocalVariableTable和LocalVariableTypeTable属性。
-keepattributes异常、签名、不推荐、SourceFile、SourceDir、LineNumberTable、合成、封闭方法、RuntimeVisibleAnnotations、RuntimeVisibleAnnotations、RuntimeVisibleParameterAnnotations、RuntimeInvisibleParameterAnnotations、AnnotationDefault、InnerClass、*Annotation*
@Raghunandan您发布的评论是不相关的!!你在这里回答了别人的问题!!请在@Shraddha上找到我的博客,谢谢提醒。可能是我的浏览器打开了一个错误的选项卡。如果我不清楚,很抱歉-我不想指定接口名称。我正试图找到一个普遍的解决办法。可能吗?我已经编辑了我的答案。注意答案中的“*”,只要你想保持它的通用性,就写“*”。请关注博客,它将帮助你。它有一个android应用程序的例子如果我错了请纠正我,但是按照你的建议做,会保留类名和所有方法名,但它们也不会被混淆。我按照你的建议做了-现在我所有的代码都没有被混淆:)哦,是吗,我想在这种情况下我需要进一步挖掘它,“如果我能为同一个类找到任何解决方案,我会给你回电的。@RonTesler,如何只混淆一个类及其公共方法?”?
#Keeping all public class names and keep (prevent obfuscation) of their public and protected methods
-keep public class * {
public protected <methods>;
}
# Keep (prevent obfuscation) all public and protected methods in non-public classes.
# Notice that the non-public class names will still get obfuscated
-keepclassmembers !public class * {
public protected <methods>;
}
# Don't keep the local variables attributes (LocalVariableTable and LocalVariableTypeTable are dropped).
-keepattributes Exceptions,Signature,Deprecated,SourceFile,SourceDir,LineNumberTable,Synthetic,EnclosingMethod,RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations,AnnotationDefault,InnerClasses,*Annotation*