Retrofit2 + RxJava: „Unable to create call adapter for rx.Observable“

If you have trouble with Retrofit2 and RxJava you should doublecheck you Retrofit setup. To be honest I write the blogpost because it happend to me and I did not found a good answer on google.
A really common exception that you get when when Retrofit2 is missing the right call adapter is this:
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Unable to create call adapter for rx.Observable<java.util.ArrayList<java.util.ArrayList<java.lang.String>>>
    for method RtiApi.getSensors
at retrofit2.ServiceMethod$Builder.methodError(
at retrofit2.ServiceMethod$Builder.createCallAdapter(
at retrofit2.ServiceMethod$
at retrofit2.Retrofit.loadServiceMethod(
at retrofit2.Retrofit$1.invoke(
at com.sun.proxy.$Proxy0.getSensors(Unknown Source)
If you want to use Retrofit2 and RxJava you gradle or maven should include the following packages:
compile 'io.reactivex:rxjava:1.0.10'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
When you create your Retrofit object don’t forget to add the RxJava call adapter, because that is the „thing“ that brings the functionality of emitting rx observables.
final Retrofit retrofit = new Retrofit.Builder()


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.