Has anyone ever used Moshi as a converter for retr...
# squarelibraries
i
Has anyone ever used Moshi as a converter for retrofit. I am having some problems with Array List. Exception is thrown because I don't have an adapter for array list. I don't quite understand what I am supposed to do here. Retrofit version 2.5.0.
Caused by: java.lang.IllegalArgumentExceptio:Platform java.util.ArrayList<java.lang.String> (with no annotations) requires explicit JsonAdapter to be registered
e
Have you try using
List
instead of
ArrayList
? I’m having no trouble using Retrofit with Moshi.
g
Looks that this is expected behaviour, you need explicit adapter for this case https://github.com/square/moshi/blob/moshi-parent-1.8.0/moshi/src/test/java/com/squareup/moshi/MoshiTest.java#L1008
And I think Edward is right, use List instead, Moshi doesn’t support out of the box serializers for concrete implementation of list, but supports abstract List implementation
i
Thanks!! It worked!