I get this error:
FATAL EXCEPTION: main
E/AndroidRuntime: java.lang.AbstractMethodError: abstract method not implemented
at retrofit.RxJavaCallAdapterFactory.get(RxJavaCallAdapterFactory.java)
at retrofit.Retrofit.nextCallAdapter(Retrofit.java:189)
at retrofit.Retrofit.callAdapter(Retrofit.java:175)
at retrofit.MethodHandler.createCallAdapter(MethodHandler.java:45)
at retrofit.MethodHandler.create(MethodHandler.java:26)
at retrofit.Retrofit.loadMethodHandler(Retrofit.java:151)
at retrofit.Retrofit$1.invoke(Retrofit.java:132)
at $Proxy0.getPosts(Native Method)
when trying to use RxJavaCallAdapterFactory on retrofit. I'm using com.squareup.retrofit:retrofit:2.0.0-beta1
and com.squareup.retrofit:adapter-rxjava:2.0.0-beta1
.
Here's how I created the api interface:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(FORUM_SERVER_URL)
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
mForumApi = retrofit.create(ForumApi.class);
The FORUM_SERVER_URL isprivate static final String FORUM_SERVER_URL = "http://jsonplaceholder.typicode.com";
my interface method is:
@GET("/posts")
public Observable<List<Post>> getPosts();
I call it via:
mForum.getApi()
.getPosts()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<Post>>() {
@Override
public void onCompleted() {}
@Override
public void onError(Throwable e) {}
@Override
public void onNext(List<Post> posts) {
mView.displayPosts(posts);
}
});
}
getApi returns mForumApi
getPosts is where the error happens, it's the API call
For me it turned out that I was using different beta versions of the components
Changing (notice beta1):
compile 'com.squareup.retrofit:converter-simplexml:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
to (now beta2)
compile 'com.squareup.retrofit:converter-simplexml:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
made it work for me.
Stupid error but yeah...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With