如何配置ProGuard以保留内部类成员的名称? [英] How to configure ProGuard to keep names of inner class members?

查看:195
本文介绍了如何配置ProGuard以保留内部类成员的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ProGuard混淆我的应用程序,我还希望某些内部类的成员保留其名称.这是因为我在Jackson中使用这些类来与JSON进行相互转换. 我的来源:

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;
    }

}

我希望上面的代码可以自我解释.我试图通过proguard-project.txt中的此命令来实现这一点

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.

推荐答案

我很确定这样的方法可以解决问题:

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.

这篇关于如何配置ProGuard以保留内部类成员的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆