来源示例:
// this is package visible interface
interface MyInterface {
void foo();
}
public class MyClass1 implements MyInterface {
// some public class members which should not be obfuscated
// ...
// this is MyInterface implementation, this method should be obfuscated:
void foo() {}
}
// other classes which implement MyInterface
...
如何将所有公共(public)成员保留在 MyClass1 和其他类中,同时仅混淆 MyInterface.foo() 实现。
最佳答案
考虑到这只是您想要混淆的一种方法,为什么不将您的 void foo()
方法重命名为 void y()
(或者你喜欢的一些随机字母)?
如果您在调试时确实无法记住一个名称奇怪的方法,则必须单独-keep
所有其他方法。
另一种选择是将方法提取到另一个类,或者创建一个子类,但这可能不是您想要的。
关于java - 如何在 proguard 混淆过程中保留除一名之外的所有公共(public)成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12333221/