相关疑难解决方法(0)

(Retrofit)找不到类崩溃应用程序的转换器

所以Retrofit 2.0.0最近发布了,并没有真正的任何更新示例如何使用它,但我试图实现它的基本API调用.我得到了一个

java.lang.IllegalArgumentException: Unable to create converter for class` 
Run Code Online (Sandbox Code Playgroud)

引起的

Caused by: java.lang.IllegalArgumentException: Could not locate converter for class orbyt.app.dataclass. Tried:
* retrofit.OkHttpBodyConverterFactory
Run Code Online (Sandbox Code Playgroud)

在尝试进行api调用时.

java android retrofit

77
推荐指数
4
解决办法
3万
查看次数

改造转换器工厂无法访问GsonConverterFactory

我已将这些依赖项包含在我的项目中:

编译'com.squareup.retrofit:retrofit:2.0.0-
beta2'compile'c​​om.squareup.retrofit:converter-gson:2.0.0-beta1'

我有一个班级,我将通过改造访问我的api:

 public static  <S> S createService(Class<S> serviceClass, String baseUrl) {


        Retrofit builder = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(GsonConverterFactory.create())
                .build();    

            RestAdapter adapter = builder.build();*/

        return  builder.create(serviceClass);
    }
Run Code Online (Sandbox Code Playgroud)

现在,它给了我这个编译时错误:

错误:(24,17)错误:类Builder中的方法addConverterFactory无法应用于给定类型; 必需:工厂发现:GsonConverterFactory原因:实际参数GsonConverterFactory无法通过方法调用转换转换为Factory

我怎么解决这个问题?我按照文档.怎么了?

android gson retrofit

56
推荐指数
2
解决办法
4万
查看次数

标签 统计

android ×2

retrofit ×2

gson ×1

java ×1