Proguard obfuscation results in java.lang.IllegalArgumentException: class declares multiple JSON fields named “a”

筅森魡賤 提交于 2019-12-04 03:52:14

You seem to be specifying the ProGuard option -overloadaggressively in your proguard-project.txt. It overloads field names and method names to the same obfuscated names, e.g. 'a', as long as the signatures of the fields and methods are different. It's valid for class files, but GSON clearly doesn't like it, so you should avoid the option.

The reason that only keeping the name of the class without preserving member names doesn't work is because the member names are what is causing the error. Proguard is renaming multiple members to the same name 'a', which is perfectly valid in classfiles. However, the tool you're using doesn't like having multiple members with the same name so it throws an error.

The solution is therefore to stop Proguard from renaming the members of that class. There's probably also a Proguard setting to avoid duplicate names, but I'm not familiar enough to say what it is.

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