Android retrofit Could not locate ResponseBody converter for interface

retrofit默认转换string成json obj,如果不需要gson转换,那么就指定泛型为ResponseBody,不要设置gson转换器

 *  只能是ResponseBody,子类都不行,同理,下载上传时,也必须指定泛型为ResponseBody

示例

public interface ZhailuData1 {
    @GET("api/v1/{id}")
    Call<ResponseBody> getZhailuData(@Path("id") String  index);
}

//而不能是:
 @GET()
Call<String> getZhailuData(@Path("id") String  index);


//如果这样指定,意思是,使用retrofit内部的json转换器,将response里的数据转换成一个实体类xxx,比如UserBean之类的,而String类明显不是一个有效的实体类,自然转换失败.

猜你喜欢

转载自blog.csdn.net/yh18668197127/article/details/85067789