Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep inner interface method names in proguard

Lets say I have..

public class SomeClass {


    public interface someInterface {

        public void firstMethod(String variable);


        public void secondMethod(String variable);


        public void thirdMethod();

    }
}

and I do..

-keep,includedescriptorclasses public class com.somepackage.SomeClass {
    <fields>;
    <methods>;
}

-keep public interface com.somepackage.someInterface {*;}

I end up with

public interface someInterface {

        public void a(String variable);


        public void a(String variable);


        public void a();

    }

How do I ensure this interface's method names are not obfuscated while still obfuscating the rest of the class?

like image 872
VicVu Avatar asked Sep 03 '14 22:09

VicVu


3 Answers

ProGuard uses the naming convention of Java bytecode, as seen in class file names and stacktraces. Therefore:

-keep public interface com.somepackage.SomeClass$someInterface {*;}
like image 195
Eric Lafortune Avatar answered Nov 20 '22 00:11

Eric Lafortune


I tried the following and it seemed to work:

-keep interface com.somepackage.SomeClass$someInterface
like image 2
Phileo99 Avatar answered Nov 20 '22 00:11

Phileo99


For those who are looking for how to keep a custom annotation (which is defined in a @interface in java) retaining its all members,

you should actually use like below to keep it:

-keep @interface com.your.annotation.interface. {*;}
like image 1
SebastianX Avatar answered Nov 19 '22 23:11

SebastianX