Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create call adapter for retrofit2.Response<...>

My Api:

@GET("/cinema/notShownMovies")
fun getNotShownMovies(
   @Query("token") token: String
): Response<GetMovieResponse>

Exception when trying to call API:

java.lang.IllegalArgumentException: Unable to create call adapter for retrofit2.Response<...data.GetMovieResponse> for method InstanceApi.getNotShownMovies Unable to create call adapter for retrofit2.Response<...data.GetMovieResponse> for method InstanceApi.getNotShownMovies

I don't know where to start. All other API calls work fine which is also defined in the same API class. Maybe a model error?

like image 335
kaulex Avatar asked Jun 19 '20 06:06

kaulex


1 Answers

Just add suspend modifier if using coroutines. This will solve the problem.

Otherwise your issue is likely because there is no Call adapter added when instantiating your Retrofit object. For example, for RxJava2, you can include a call adapter by adding this line while building it.

.addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io()))
like image 187
Abdul Mateen Avatar answered Oct 05 '22 14:10

Abdul Mateen