所以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调用时.
我已将这些依赖项包含在我的项目中:
编译'com.squareup.retrofit:retrofit:2.0.0-
beta2'compile'com.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
我怎么解决这个问题?我按照文档.怎么了?