Unable to create call adapter for class example.Simple

后端 未结 14 1220
隐瞒了意图╮
隐瞒了意图╮ 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:32

    add dependencies:

    compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
    compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
    

    create your adapter this way:

    Retrofit rest = new Retrofit.Builder()
        .baseUrl(endpoint)
        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
        .addConverterFactory(SimpleXmlConverterFactory.create())
        .build();
    

    addCallAdapterFactory () and addConverterFactory () both need to be called.

    Service:

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

    Modify Simple to Call.

提交回复
热议问题