I am one of the coauthors of Gson library (a Java to JSON conversion tool). Several users use our library in Android projects. Gson uses reflection to bind Java fields to JSON fields. Gson also supports generic fields. For example, a List<LineItem> will be mapped to a JSON array of LineItem. To do this binding correctly, Gson uses the reflection on the fields to get the parameterized type (note that Type erasure does not affect the fields of a class).
However, it seems like when proguard is run on an Android app with Gson, this generic type information stored for a field is lost. A field of type List<LineItem> becomes of type List. This means that Gson no longer has enough information to do the data binding correctly.
I have written an example Android application that demonstrates this behavior. Please see:
http://code.google.com/p/google-gson/source/browse/#svn%2Ftrunk%2Fexamples%2Fandroid-proguard-example
In specific, Change list http://code.google.com/p/google-gson/source/detail?r=877 has the code that shows that proguard is erasing type information.
Please provide a fix to ensure that generic information is saved for fields of classes kept with --keep.
By default, ProGuard indeed removes generic type information, since the JVM doesn't use it. This information is stored in attributes. If you want to keep them, you have to add this option:
-keepattributes Signature
This is illustrated in the ProGuard Manual > Examples > A typical library