我有这个班级
public class MyClass extends StringType implements ProtectedAgainstProguard {
private static final String delimiter = "#";
private static final MyClass singleton = new MyClass ();
private MyClass() {
super(someStuff);
}
public static MyClass getSingleton() {
return singleton;
}
@Override
public Object someMethodA() {
}
@Override
public Object someMethodB() {
}
}
这是我的ProGuard配置:
-keep public interface com.example.android.application.ProtectedAgainstProguard
-keep public class * implements com.example.android.application.ProtectedAgainstProguard
-keep class * implements com.example.android.application.ProtectedAgainstProguard
-keep public class * extends com.example.android.application.ProtectedAgainstProguard
-keep class * extends com.example.android.application.ProtectedAgainstProguard
,这是此类的mapping.txt
com.example.android.domain.MyClass -> com.example.android.domain.MyClass :
com.example.android.domain.MyClass singleton -> a
15:16:void <init>() -> <init>
24:28:java.lang.Object someMethodA() -> someMethodA
34:38:java.lang.Object someMethodB() -> someMethodB
12:12:void <clinit>() -> <clinit>
正如你可以看到static final
单例(不知道它的成员或方法,我认为它的方法,是否被混淆了)。
我怎么告诉proguard只是把它的手放在整个班级及其中的所有东西上?
我不想列出我想要保留的特定类及其特定方法/成员,我只想要一个通用规则,“不要对实现ProtectedAgainstProguard
的类做任何事情”
答案 0 :(得分:1)
您可以使用: -
-keep interface com.example.android.application.ProtectedAgainstProguard {*;}
-keepclasseswithmembers class * implements com.example.android.application.ProtectedAgainstProguard{*;}
-keepclasseswithmembers interface * extends com.example.android.application.ProtectedAgainstProguard{*;}
答案 1 :(得分:0)
结果是为了保护班级成员,我们需要在规则末尾添加{ *; }
- 因为keep
本身并不是很有用。
-keep public interface com.example.android.application.ProtectedAgainstProguard { *; }
-keep public class * implements com.example.android.application.ProtectedAgainstProguard { *; }
-keep class * implements com.example.android.application.ProtectedAgainstProguard { *; }
-keep public class * extends com.example.android.application.ProtectedAgainstProguard { *; }
-keep class * extends com.example.android.application.ProtectedAgainstProguard { *; }