android - IllegalArgumentException: Could not locate call adapter for rx.Observable RxJava, Retrofit2 -


i getting above error while calling rest api. using both retrofit2 , rxjava.

servicefactory.java

public class servicefactory { public static <t> t createretrofitservice(final class<t> clazz, final string endpoint){      retrofit retrofit = new retrofit.builder()             .baseurl(endpoint)             //.addconverterfactory(gsonconverterfactory.create())              .build();      t service = retrofit.create(clazz);     return service; } 

}

movieservice.java

public interface movieservice{ //public final string api_key = "<apikey>"; public final string service_end = "https://api.mymovies.org/3/"; @get("movie/{movieid}??api_key=xyz") observable<response<movies>> getmovies(@field("movieid") int movieid); 

}

inside mainactivity

      movieservice   tmdbservice = servicefactory.createretrofitservice(movieservice.class, movieservice.service_end);     observable<response<movies>> responseobservable = tmdbservice.getmovies(400);     responseobservable .subscribeon(schedulers.newthread())             .observeon(androidschedulers.mainthread())             .subscribe(new subscriber<response<movies>>() {                 @override                 public void oncompleted() {                  }                  @override                 public void onerror(throwable e) {                  }                  @override                 public void onnext(response<movies> moviesresponse) {                  }             }); 

be sure add compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta3' or whatever beta version using dependencies, , configure retrofit converter:

retrofit retrofit = new retrofit.builder()     .baseurl(endpoint)     .addconverterfactory(gsonconverterfactory.create())     .addcalladapterfactory(rxjavacalladapterfactory.create())     .build(); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -