iamantoniodinuzzo / CineMates

CineMates is a modern android application for movie fans in which you will be able to search for movies and consult information provided by The Movie DB.
GNU General Public License v3.0
15 stars 3 forks source link

MovieService's GET requests crash the app #48

Closed jxareas closed 2 years ago

jxareas commented 2 years ago

As of now, calling some methods inside of the init block of HomeViewModel instantly crashes the app, due to the fact that the MovieService is not deserializing the data correctly. Furthermore, the GET requests for trending movies / actors by week return a bad request, as evidenced below, by the LoggingInterceptor.

result

iamantoniodinuzzo commented 2 years ago

I solved the Bad Request regarding getTrendingmethods. The error was about the parameters passed to the called function. Through enumerations I was not passing the string but rather the name of the argument (MediaTYpe.PERSON.name instead of calling the .toString())

Now all functions in the HomeViewModel init block cause error on the feat_viewModel_each_view branch.

2022-08-25 10:53:52.763 5856-5856/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.cinemates, PID: 5856
    java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
        at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80)
        at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)
        at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
        Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7878d7a, Dispatchers.Main.immediate]
iamantoniodinuzzo commented 2 years ago

I am already proceeding to resolve the error. In the API interface I was placing a Response<List<Movie>> as the return, instead I had to return an object of type Response, so I created a reusable class for lists of movies , people, reviews etc.