Implementing Proguard in Android throws error Gson

By : Munchoo
Source: Stackoverflow.com
Question!

I am trying to implement Proguard for my Android project. Am using Android Studio for doing the same. But finding lot of difficulties while implementation. Is there a good tutorial to overcome all the issues. In the below code which I have used got an exception like cannot be cast. Can anyone help me to get rid of this issue.

In my proguard-rules.txt I have used the below lines too. But it dint resolve my issue

-keep class com.google.gson.**{*;}
-dontwarn com.google.gson.**


public class Home_CityDet implements Serializable{

private static final long serialVersionUID = 1L;
@SerializedName("key")
public String key;
@SerializedName("value")
public String value ;   
}

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to webservices.responses.Home_CityDet
By : Munchoo


Answers

I had to add to the progaurd configuration:

-keepattributes Signature
-keepattributes *Annotation*
-keep class Home_CityDet  {
*;
}

and the error magically disappeared

By : nont


This video can help you solving your question :)
By: admin