Reputation: 315
I get this error message if I try to use GsonConvertFactory:
Cannot resolve Symbol
GsonConverterFactory
I am using it like this:
return new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
//.addConverterFactory(MoshiConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
This is my gradle file (Module: app):
dependencies {
...
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
compile 'com.google.code.gson:gson:2.7'
}
Upvotes: 10
Views: 10844
Reputation: 1249
Change this
implementation 'com.google.code.gson:gson:2.7'
To this
implementation 'com.google.code.gson:gson:2.8.6'
Upvotes: 1
Reputation: 147
Just add gson converter factory gradle verson implementation 'com.squareup.retrofit2:converter-gson:latest.version'
Upvotes: 0
Reputation: 1852
you shoul add these library to build.gradle file
compile 'com.squareup.retrofit2:converter-gson:2.3.0' compile 'com.squareup.retrofit2:retrofit:2.3.0'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
testCompile 'junit:junit:4.12'
}
Upvotes: 1
Reputation: 6704
GsonConverterFactory resides in following dependency so, add this in your build.gradle
as dependency.
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
Upvotes: 20