0

I'm getting the crash in android retrofit for release build

Last parameter must be of type Callback<X> or Callback<? super X>.
at retrofit.RestMethodInfo.methodError(Unknown Source)
at retrofit.RestMethodInfo.parseResponseType(Unknown Source)
at retrofit.RestMethodInfo.<init>(Unknown Source)
at retrofit.RestAdapter.getMethodInfo(Unknown Source)
at retrofit.RestAdapter$RestHandler.invoke(Unknown Source) 

I tried Proguard rules from this reference Proguard issue while using GSON and https://github.com/square/retrofit/issues/372 but it's not working

Community
  • 1
  • 1
user12378334
  • 117
  • 1
  • 14

1 Answers1

0

Ok it looks like you have 2 options:

1) Move all the deserialization and serialization models to a specific package and in proguard-rules.pro add the full package name:

e.g.

-keep class com.mycompany.myproject.mydata.model.** { *; }

and then it will work because those files will not be proguarded.

2) You can use the @SerializedName and the @Export annotations in the data members of your models like this:

public class KeyValue {
    @SerializedName("Key")
    @Expose
    private String key;
    @SerializedName("Value")
    @Expose
    private String value;

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}

and then you can even proguard the models.

Hope it will help!!!

matrix
  • 314
  • 4
  • 24