小编Pas*_*Lzx的帖子

改造和 SimpleXmlConverterFactory

我在改造和 XML 方面遇到问题,我使用 SimpleXmlConverterFactory,并且出现此错误: 原因为:“java.lang.IllegalArgumentException:无法找到 java.util.List 的 ResponseBody 转换器。尝试过:
*retrofit2.BuiltInConverters *retrofit2。转换器.simplexml.SimpleXmlConverterFactory”

等级:

compile 'com.google.code.gson:gson:2.8.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.3.0') {
    exclude group: 'xpp3', module: 'xpp3'
    exclude group: 'stax', module: 'stax-api'
    exclude group: 'stax', module: 'stax'
}
Run Code Online (Sandbox Code Playgroud)

服务 :

        Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(URL)
            .client(buildHttpClient())
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .build();

private OkHttpClient buildHttpClient() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    return (new OkHttpClient.Builder())
            .addInterceptor(buildDefaultHeadersInterceptor())
            .addNetworkInterceptor(buildLogInterceptor())
            .build();
}
Run Code Online (Sandbox Code Playgroud)

模型 :

    @Root(name = "item")
    public class Item {

    @Element(name = …
Run Code Online (Sandbox Code Playgroud)

java xml android retrofit simple-xml-converter

5
推荐指数
1
解决办法
3991
查看次数

标签 统计

android ×1

java ×1

retrofit ×1

simple-xml-converter ×1

xml ×1