改造转换工厂无法访问GsonConverterFactory [英] retrofit convertor factory can not access GsonConverterFactory

查看:3382
本文介绍了改造转换工厂无法访问GsonConverterFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经包含下面的依赖关系到项目

i have included below dependencies to project

编译com.squareup.retrofit:改造:2.0.0-β2'
  编译com.squareup.retrofit:转炉GSON:2.0.0-β1

compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'

我上课我要去的地方,通过改造来访问我的API的:

I have class where i am going to access my api's via retrofit:

 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);
    }

而现在,当我要运行它给了我一个错误:

And now when i am going to run it gives me an error:

错误:(24,17)错误:类生成器方法addConverterFactory   不能被应用到给定的类型;要求:厂发现:   GsonConverterFactory原因:实际参数GsonConverterFactory   无法通过方法调用转换转换为工厂

Error:(24, 17) error: method addConverterFactory in class Builder cannot be applied to given types; required: Factory found: GsonConverterFactory reason: actual argument GsonConverterFactory cannot be converted to Factory by method invocation conversion

何,我可以解决这个问题?我已经做了所有它的文档。这是怎么回事错在这里?

Ho i can solve it? I have done all it with documentation. What is going wrong here?

推荐答案

尽量使用同一版本的改造和转换器,GSON - 2.0.0-β2。您正在使用β2 的改造和β1的的转换器。

Try to use same version for retrofit and converter-gson - 2.0.0-beta2. You are using beta2 for retrofit and beta1 for converter.

compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'

这篇关于改造转换工厂无法访问GsonConverterFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆