0

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.

Aman Verma
  • 3,155
  • 7
  • 30
  • 60
  • as far as I'm aware, ProGuard can only operate on Java code (not on the XML), so if they obfuscate the activity names, it would mess up with the manifest. So maybe android plugin auto add some rule to not mess up the manifest declared stuff, which we developers should not mess with. All of this is just assumption and deduction, not an actual informed answer. – Budius Nov 25 '16 at 20:49

1 Answers1

2

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

Community
  • 1
  • 1
Jared Rummler
  • 37,824
  • 19
  • 133
  • 148