Keep method name from Obfuscator Proguard

本秂侑毒 提交于 2019-12-13 05:52:56

问题


How can I prevent method SendToGroup() from Obfuscator in proguard.

Coz, this method name will be call from server side and need to be same name (dynamic method call). It's a push from signalR.

public class main {

    private class inner implement x {

        @Override
        public Object dynamic {

            return new Object {

                @SuppressWarnings("unused")
                public void SendToGroup(String message) {
                    androidNotification(message);
                }
            };
        }
    }
}

I have seen this and this but still not work and not understand.

Please advice.


回答1:


In order to keep an interface in progourd use the -keep public interface statement.

For example:

-keep public interface com.your_package_name.class_name$someInterface {*;}

In order to keep a class member in progourd use the - keepclassmembers statement.

For example:

-keepclassmembers class com.example.project.inner {
    private static void someclass(java.lang.String);
}



回答2:


annotate the method with @Keep



来源:https://stackoverflow.com/questions/31607727/keep-method-name-from-obfuscator-proguard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!