[英]How to keep class method names that override\implements another method from being obfuscated?
如果我有一个Class B
实现Interface A
而Proguard不知道该接口是否存在,我怎样才能保留实现接口A抽象方法的方法的名称?
请注意我想保留方法名称,但我确实希望它们的内容被混淆。
更新:这就是我所拥有的(请注意评论):
public class MyService extends Service {
// an anonymous class that implements ServiceConnection
private ServiceConnection myConnection = new ServiceConnection()
{
// don't change the following method's name
@Override
public void onServiceConnected(ComponentName className, IBinder service)
{
// I want this section to be obfuscated
}
}
我想要这种情况的一般解决方案 - 我不想在ProGuard配置中声明接口名称。
所以你的.pro文件应该是这样的 -
#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*
我为Progaurding Android应用程序编写了博客。 请检查以下链接
http://techspreadwithshraddha.wordpress.com/2013/03/26/android-progaurd/
ProGuard可以按照您的描述进行操作。 如果您不希望它重命名类和方法,请尝试以下方法:
-keep,allowshrinking,allowoptimization class * { <methods>; }
希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.