Warm tip: This article is reproduced from stackoverflow.com, please click
obfuscation proguard

Keep class methods but obfuscate packages in proguard

发布于 2020-03-27 10:18:21

com.company.package1.CLASS
- public void MethodA ();
- public void MethodB ();
- public void MethodC ();

The CLASS has 3 public methods and I need to keep them, but the package could be remove. I.e. the expected result could be

a.b.c.CLASS or a.b.c.D(alternative, the class name is obfuscated too)
- public void MethodA ();
- public void MethodB ();
- public void MethodC ();

I wrote some scripts but how to extends them in order to fulfill my requirement.

    -keep class 
        com.company.package1.CLASS {
        public <methods>;
    }

    -repackageclasses ''
    -allowaccessmodification
Questioner
Danielle
Viewed
25
Eric Lafortune 2013-03-08 23:53

You can use -keepclassmembers instead of -keep -- cfr. ProGuard manual > Usage > Overview of -keep options.