How to tell Proguard about class name confusion

I would like proguard to obfuscate class names. I have this line in Proguard.cfg

-keepclasseswithmembers class * { public static <fields>; } -keepnames class * implements java.io.Serializable -keep public class com.google.** 

And I notice that what is not confused is the names of the classes. So, running jdgui, I see com / test / ABCD / ActualClass.java public class ActualClassName expands activity, etc.

In addition, I see methods that return real class names. as

  ActualClassname aa(); 

and imports expressions such as

  import com.abcd.ActualClassName 

How to force Proguard to obfuscate the class name itself. This is not only for the actions that I see that my adapters are not tangled. Well, obfuscation happens, but not class names.

Are rules higher than preventing class names from getting confused?

Update: Since then I have removed the above rules, and the Utility class, which does not extend anything from Android, is not confused. Now I'm wondering if there is some implicit rule about storing class class names that are referenced by classes that are stored as derived classes? Classes whose names are not confused have several things in common:

1) Static methods 2) Import of other types that are stored as those that are produced from activities or can be serialized. 3) They have methods with parameters of other classes (some of them may need to be saved).

However, there is no where I specifically request that these utility classes persist.

+6
source share
2 answers

There are several classes in your code that must keep the same fully qualified class name so that so they can be found. One example above is all the Activity classes, as they are defined in the manifest by their full name as a string. If renames a class, then Android can no longer find them.

A typical Proguard configuration will refer to the Proguard configuration in the Android SDK, which will contain several important lines like this:

 -keep public class * extends android.app.Activity 
+3
source

I think your problem comes from your first line: '-keepclasseswithmembers' includes the class name, so in your case, any class with a static field will keep its name. Changing it simply with "-keepclassmembers" will confuse class names, leaving static fields unchanged (which I assume you want to do).

However, I'm not sure why you want to do this. If you are trying to save static variable names, would you also like to save class names, seeing exactly how you will access static fields? Why are you trying to save all your static variable names?

+1
source

Source: https://habr.com/ru/post/915143/


All Articles