Using GSON with proguard enabled

前端 未结 5 1856
太阳男子
太阳男子 2020-12-01 03:45

My code works perfectly without proguard, but GSON doesn\'t work when proguard is enabled.

This is the part of code where it doesn\'t works

JSONArray         


        
5条回答
  •  情话喂你
    2020-12-01 04:25

    When you apply proguard script to your model classes it obfuscates their names and their properties' names. So after obfuscation of String descripcionCategoria; you will have something like String aaaa;

    Gson works through java reflection and it will try to use a property name while parsing data. So, after applying obfuscation to model classes you won't be able to parse your data.

    So, exclude model classes from your proguard script and you will be able to parse again.

提交回复
热议问题