Dear @noiling,
Welcome to the PG community!
In this case, you should provide a keep option for the serialized class and its members. This is the safest approach.
For example
-keepnames com.example.myserializableclass{*;}
-keepclassmembers com.example.myserializableclass{*;}
This way, the names of those serializable objects are not obfuscated. The issue here, resides in the way serialization works. Currently, names of the serialized object (and its members) are being obfuscated first, and then get serialized to a server, second. Initially, this works fine when you serialize data to the server. But, as you noticed, the problem will occur when you to de-serialize that data.
When you try deserializing that data from the server (using the original names) the app crashes, because the server does not have a mapping file, and all the names (which you’re now trying to deserialize by the original identifier) were previously obfuscated by ProGuard prior to serializing that data to the server. So, when you try to de-serialize a model or dto by its original name, it can’t be found… the name is actually changed. In actuality, you would need to retrieve/deserialize it but the obfuscated name for deserialization to work properly. But that’s not how your code works.
Luckily, there is a simple fix.
Providing a keep rule for those serialized parts, will ensure those names are not obfuscated by ProGuard. As a result, when you try to deserialize those pieces of data from the server later on, the names wont be changed, can once again be found by the original name, and the app won’t crash when anymore.
You can read more about this in our manual here:
Please let me know if you have any questions.
Kind regards,
Jack