Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit 2.0: Unable to create call adapter for class

I'm using Retrofit 2.0-beta1. How can I make a simple synchronous request and deserialize a JSON response as a POJO list? This is my interface:

public interface ArticlesAPI {
    @GET("/articles")
    List<ArticleResource> getArticles();
}

and

public class ArticleResource {

    public String id;
    public String name;

    public Article toArticle() {
        return new Article(id, name);
    }
}

but I get this error:

>  Unable to create call adapter for
> java.util.List<com.bla.bla.rest.resources.ArticleResource>

Retrofit build

Retrofit retrofit = (new Retrofit.Builder()).baseUrl(this.baseUrl).build();
ArticlesAPI api = retrofit.create(ArticlesAPI.class);
like image 339
Héctor Avatar asked Oct 20 '15 15:10

Héctor


1 Answers

This issue can also occur if you are using kotlin coroutines and the function is not suspend function

public interface ArticlesAPI {
 @GET("url.../habits/progress/")
    suspend fun getHabitsTasks(): BaseResponse<HabitResModel>
}
like image 88
Rahul Avatar answered Oct 10 '22 12:10

Rahul