Unable to create call adapter for class example.Simple

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

    Add the following dependencies for retrofit 2

     compile 'com.squareup.retrofit2:retrofit:2.1.0'
    

    for GSON

     compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    

    for observables

    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    

    In your case for XML , you would have to include the following dependencies

     compile 'com.squareup.retrofit2:converter-simplexml:2.1.0'
    

    Update the service call as below

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

提交回复
热议问题