错误:不兼容的类型:GsonConverterFactory无法转换为Factory

sre*_*mar 6 android gson retrofit

我正在尝试使用Retrofit 2.0.0.beta2,如下所示设置Converter for Gson

 Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build();
Run Code Online (Sandbox Code Playgroud)

这个gradle抛出错误之后

GsonConverterFactory无法转换为Factory

怎么解决???

Bla*_*elt 11

你可能是第二个测试版的第一个测试GsonConverterFactoryRetrofit.请确保你有

compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
Run Code Online (Sandbox Code Playgroud)

在你的gradle中


sre*_*mar 2

我得到了这个问题...

我使用编译'com.squareup.retrofit:converter-gson:2.0.0-beta1'而不是'com.squareup.retrofit:converter-gson:2.0.0-beta2'

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.google.code.gson:gson:2.3'}
Run Code Online (Sandbox Code Playgroud)