Unable to create call adapter for class example.Simple

后端 未结 14 1223
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 23:14

I am using retrofit 2.0.0-beta1 with SimpleXml. I want the retrieve a Simple (XML) resource from a REST service. Marshalling/Unmarshalling the Simple object with SimpleXML w

14条回答
  •  被撕碎了的回忆
    2020-12-04 23:50

    Short answer: return Call in your service interface.

    It looks like Retrofit 2.0 is trying to find a way of creating the proxy object for your service interface. It expects you to write this:

    public interface SimpleService {
        @GET("/simple/{id}")
        Call getSimple(@Path("id") String id);
    }
    

    However, it still wants to play nice and be flexible when you don't want to return a Call. To support this, it has the concept of a CallAdapter, which is supposed to know how to adapt a Call into a Simple.

    The use of RxJavaCallAdapterFactory is only useful if you are trying to return rx.Observable.

    The simplest solution is to return a Call as Retrofit expects. You could also write a CallAdapter.Factory if you really need it.

提交回复
热议问题