Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: incompatible types: GsonConverterFactory cannot be converted to Factory [duplicate]

I'm trying to use Retrofit 2.0.0.beta2, when setting up the Converter for Gson like below

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

After this gradle throwing error

GsonConverterFactory cannot be converted to Factory

How to fix it ???

like image 894
sreekumar Avatar asked Oct 14 '15 07:10

sreekumar


2 Answers

you are probably the first beta of GsonConverterFactory with the 2nd beta of Retrofit. Please make sure that you have

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

in your gradle

like image 144
Blackbelt Avatar answered Sep 28 '22 08:09

Blackbelt


I got the issue...

I was using compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' instead of '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'}
like image 22
sreekumar Avatar answered Sep 28 '22 09:09

sreekumar