livedata-call-adapter icon indicating copy to clipboard operation
livedata-call-adapter copied to clipboard

java.lang.IllegalStateException:

Open mohdirfan87 opened this issue 7 years ago • 5 comments

I am using your live data adapter but I got error in observer callback, please look at the issue.

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2 path $

mohdirfan87 avatar Sep 09 '18 16:09 mohdirfan87

This is not related to the library itself it's a parse error.

Your response is expecting a object while the real response is returning an array.

leonardoxh avatar Sep 10 '18 11:09 leonardoxh

I think this api is not compatible with json array response , if it is compatible with json array response ,please give the some live of code , for your kind information i am using as:

@GET("marvel") LiveData<Resource<List<Hero>>> getHeroesLiveDataList(); i think its expecting the object and the response is json array. My question is how to deal with response of json array in case of LiveData by adding the LiveDataFactory in Retrofit library.

mohdirfan87 avatar Sep 11 '18 07:09 mohdirfan87

I can try on the weekend.

leonardoxh avatar Sep 11 '18 07:09 leonardoxh

It was expecting object because you did GET("marvel") LiveData<Resource<List>> getHeroesLiveDataList();

Instead, try GET("marvel") LiveData<Resource<List<Hero>>> getHeroesLiveDataList();

List is an object, while List<Hero> is an array

Assuming Hero is your model class.

coder966 avatar May 22 '19 02:05 coder966

I have the same error and I can´t figure out what is the error. I tried with LiveDataCallAdapter from google examples and get the same error. But If I try with Call object its works.

UPDATE: Never mind. It was my error. It is working now

sebargarcia avatar Jun 03 '19 20:06 sebargarcia