'Platform java.util.ArrayList<java.lang.String> (with no annotations) requires explicit JsonAdapter to be registered android
I'm trying to convert a JSON string to Java Object using the Moshi library for Android. The object contains a property of type
ArrayList<String>
After app run, throws following exception
Caused by: java.lang.IllegalArgumentException: Platform java.util.ArrayList<java.lang.String> (with no annotations) requires explicit JsonAdapter to be registered
for java.util.ArrayList<java.lang.String> result
for class com.xxxx.data.remote.response.NewsResponse
at com.squareup.moshi.Moshi$LookupChain.exceptionWithLookupStack(Moshi.java:348)
at com.squareup.moshi.Moshi.adapter(Moshi.java:149)
at com.squareup.moshi.ClassJsonAdapter$1.createFieldBindings(ClassJsonAdapter.java:99)
at com.squareup.moshi.ClassJsonAdapter$1.create(ClassJsonAdapter.java:82)
at com.squareup.moshi.Moshi.adapter(Moshi.java:137)
at com.squareup.moshi.Moshi.adapter(Moshi.java:97)
at retrofit2.converter.moshi.MoshiConverterFactory.responseBodyConverter(MoshiConverterFactory.java:91)
at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:362)
at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:345)
at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:124)
Solution 1:[1]
Even I've faced the same issue.
After hours of searching, found the solution by Eric helpful.
Using List instead of ArrayList solved the issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sarada |
