1

I am trying to retrieve a list of objects via Retrofit:

public interface TemplateApi {
    @GET("/api/templates")
    Observable<List<TemplateDto>> getList();
}

Here the Dto:

public class TemplateDto {
    public String id;
    public String name;

    @Override
    public String toString() {
        return this.name;
    }
}

Instead of the expected List I get a

List<LinkedTreeMap>

which leads to weird side effects (in my case toString() returns not what I would expect)

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Wolfgang
  • 2,188
  • 1
  • 25
  • 24

1 Answers1

2

Ok I found it out - Android really does not have the flattest learning curve...

The issue was not with Retrofit or Gson itself but it was the minifier (Proguard). Proguard needs to be configured in a file which is called "proguard-rules.pro" by default.

Add the following lines:

-keepattributes Signature
-keepattributes *Annotation*
-keep class com.myproject.dtos.** { *; }

Thanks to this answer.

Wolfgang
  • 2,188
  • 1
  • 25
  • 24