如果我有一个实现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配置中声明接口名称。
发布于 2013-07-16 17:56:35
所以你的.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*
发布于 2013-07-16 12:29:22
我为Android应用程序编写了一个博客。请查看下面的链接
http://techspreadwithshraddha.wordpress.com/2013/03/26/android-progaurd/
ProGuard可以做你描述的事情。如果不希望它重命名类和方法,请尝试以下方法:
-keep,allowshrinking,allowoptimization class * { <methods>; }
希望这能有所帮助
https://stackoverflow.com/questions/17675882
复制相似问题