Search code examples
gsonandroid-proguard

proguard in android - should i obfuscate gson POJOs


I am assuming i cannot obfuscate gson POJOs. if i do then gson cannot do the object mapping and deserialize json to POJO, correct ? Is there any way to obfuscate POJOs then ? Also please let me know if my thoughts are correct that obfuscating POJOs should not be done and if so what would be the proguard command to keep all pojos.


Solution

  • 5 months too late but I ran into this issue and this was the first Google result.

    My solution was just to keep all POJOs unobfuscated, the easiest way being to keep all classes that are in a "model" folder

    -keep class com.example.myapp.**.model.** {*; }
    

    This will keep all POJOs that are in any model package in your app.