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(ServiceMethod.java:720)
at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:234)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:160)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
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() .baseUrl(RtiApi.SERVICE_ENDPOINT) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build();