7

I have one method

public class XYZ {
    public void foo(boolean isAvailable) {

    }
}

I am using Proguard to obfuscate, Please let me know how can I keep the method foo with it's boolean parameter.

Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
Priyavrat
  • 451
  • 3
  • 14
  • Did you applied any proguard rule yet, such as "keep" ? See: https://stackoverflow.com/questions/7880107/in-proguard-how-to-preserve-a-set-of-classes-method-names – ashishdhiman2007 Mar 06 '19 at 11:44
  • I am keeping the class, and keeping some specific methods into it. – Priyavrat Mar 06 '19 at 11:45
  • -keepclasseswithmembernames class YourClassName { ; } // something along these lines should do – ashishdhiman2007 Mar 06 '19 at 11:46
  • Problem is that I can keep the parameter names for methods, where the parameters are of reference type. But I can't keep the primitive parameter. – Priyavrat Mar 06 '19 at 11:47
  • -keepclasseswithmembernames class YourClassName { ; } will keep all the methods, But I want a specific method only which have single boolean param – Priyavrat Mar 06 '19 at 11:48
  • annotate the method with @Keep – ashishdhiman2007 Mar 06 '19 at 11:51
  • 1
    @Keep is keeping the method but not it's parameter name. void xyz(boolean abc), here it is keeping the method xyz but obfuscating abc to b. The method name name I can already keep with my current changes. – Priyavrat Mar 06 '19 at 11:55

1 Answers1

5

You can do something like this

-keepparameternames

-keep class com.abc.XYZ {
    public void foo(boolean);
}

-keepparameternames will not obfuscate the method parameters

Uma Sankar
  • 449
  • 1
  • 8
  • 19