Proguard Obfuscation doesnt work on activities?

2019-09-14 20:28发布

i ran proguard on my project but it doesnt obfuscate my activity name. i have tried several rules and it is not working. i dont know what exactly it means for example the rule below:

-keep public class models.* {
  *;
}

and whats the difference between

-keepclassmembers class * {

}

and

-keepclasseswithmembers class * {

}

i am having difficulty on how these rules work. please help.

1条回答
Lonely孤独者°
2楼-- · 2019-09-14 20:59

During the build process, proguard checks the AndroidManifest and keeps all activity classes. This is needed for your app to run. You should not obfuscate classes which extend android.app.Activity.


See:

Why Proguard keeps Activity class in Android?

Why proguard processes AndroidManifest.xml


whats the difference between ... keepclassmembers and ... keepclasseswithmembers

According to the documentation:

-keepclassmembers

Specifies class members to be preserved, if their classes are preserved as well. For example, you may want to keep all serialization fields and methods of classes that implement the Serializable interface.

-keepclasseswithmembers

Specifies classes and class members to be preserved, on the condition that all of the specified class members are present. For example, you may want to keep all applications that have a main method, without having to list them explicitly.

See: http://proguard.sourceforge.net/manual/usage.html

查看更多
登录 后发表回答