我正在使用aurae / retrofit-logansquare来解析我的android改造项目中的json。我根据文档添加了.addConverterFactory(LoganSquareConverterFactory.create())。
模型类
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.util.ArrayList;
import java.util.List;
@JsonObject()
public class DemoModel{
@JsonField(name = "newsonair")
private List<NewsOnAir> newsonair = new ArrayList<NewsOnAir>();
public NewsOnAirList(List<NewsOnAir> newsonair) {
this.newsonair = newsonair;
}
public List<NewsOnAir> getNewsonair() {
return newsonair;
}
public void setNewsonair(List<NewsOnAir> newsonair) {
this.newsonair = newsonair;
}
@Override
public String toString() {
return "NewsOnAirList{" +
"newsonair=" + newsonair +
'}';
}
}
运行致命异常时无法为类创建转换器。 以下是错误日志。
Caused by: java.lang.IllegalArgumentException: Could not locate ResponseBody converter for class info.website.android.app.api.models.DemoModel.
Tried:
* retrofit2.BuiltInConverters
* com.github.aurae.retrofit2.LoganSquareConverterFactory
at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:346)
at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:308)
at retrofit2.ServiceMethod$Builder.createResponseConverter(ServiceMethod.java:704)