Proguard 仅保留 class 名称以及 class 内的所有成员和方法

Proguard keep only class name and all members and methods inside the class

文档不够清楚,无法对此进行解释。

-keepnames class_specification

Short for -keep,allowshrinking class_specification

Specifies classes and class members whose names are to be preserved, if they aren't removed in the shrinking phase. For example, you may want to keep all class names of classes that implement the Serializable interface, so that the processed code remains compatible with any originally serialized classes. Classes that aren't used at all can still be removed. Only applicable when obfuscating.

请任何人解释一下 keepnames 属性。这将仅保留 class 名称或 class 的所有成员和方法。请给我一种方法,只保留 class 名称,而不是 class.

的所有方法和成员

抱歉英语不好。我以为我清楚地解释了我的问题。

请仔细阅读文档;它具有完全理解所需的一切和​​一点点试验和错误。 :)

proguard documentation

顺便说一下,为了保留 class 名称,将以下行添加到您的 progurard 文件

-keepnames class your.package.name.ClassName {

}

示例:

-keepnames class com.example.test.domain.Person {

}