How to configure ProGuard to keep names of inner class members?

本秂侑毒 提交于 2019-12-11 13:59:54

问题


I want to obfuscate my app with ProGuard and I also want member of some inner classes to keep their names. This is because I use these classes in Jackson for converting to and from JSON. My source:

// this class mainly serves as a container for a group of related inner classes
public class MyOuterClass
{
    public class IDontWantToKeepThisClassName1
    {
        public String IWantToKeepThisName1;
        public float IWantToKeepThisName2;
    }

    public class IDontWantToKeepThisName2
    {
        public IDontWantToKeepThisClassName1 IWantToKeepThisName3;
        public float    IWantToKeepThisName4;
    }

}

I hope that above code is self explanatory. I tried to achieve this with this command in proguard-project.txt

-keepclassmembernames class com.myapppackage.MyOuterClass$**

Yet this does not work. Inner class members are still obfuscated. It takes insane amount of time to test various options trying to guess correct options or syntax because each change requires package export to see if it works.


回答1:


I am pretty sure something like this should do the trick:

-keepclassmembernames class com.myapppackage.MyOuterClass$** { *; }

So please double check. Testing showed that { *; } part is necessary. Although I cannot explain why. Could someone with insight please elaborate.



来源:https://stackoverflow.com/questions/30217153/how-to-configure-proguard-to-keep-names-of-inner-class-members

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