Open harshmittal29 opened 4 years ago
Hi ! I had same issue, after 2 days investigating I discovered it is related with minify true in your graddle.
If is your case, you have to add all classes you use on the parse of GSON to your proguard-rules.txt
-keepattributes Signature -keep class sun.misc.Unsafe { *; } -keep class com.your.Package.yourclases.** { *; }
Hope it helps.
Kind regards
@marcosybarraa yes added classes to proguard rules work. Is there a more cleaner way to do this without adding the classes? Adding classes manually can induce errors. Any other way GSON team is aware of?
you need to keep those JavaBean files with -keep
while gson not supportted.
Any news on this? We enable R8 and start to get this problem, and keep all our data classes is not something practical, Thanks
The R8 FAQ contains hints for usage with Gson. In general if you notice specific information being missing in the android-proguard-example of Gson, it would be good to create an issue or pull request for this.
When I generate release build, GSON is not able to parse my API response.
I am using retrofit and gson Parser. com.squareup.retrofit2:retrofit com.squareup.retrofit2:converter-gson Retrofit version 2.6.0
implementation "com.google.code.gson:gson:$rootProject.gsonVersion" Version : '2.8.5'
My proguard for GSON
Proguard for retrofit2
I am using R8 enabled compilation
But when I include my models in proguard, the parsing seems to work
Can someone suggest how can I make parsing work without including models inside proguard?