java – Keep inner interface method names in proguard-ThrowExceptions

Exception or error:

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 {

-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?

How to solve:

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

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


I tried the following and it seemed to work:

-keep interface com.somepackage.SomeClass$someInterface


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. {*;}

Leave a Reply

Your email address will not be published. Required fields are marked *