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'
}
GsonConverterFactory resides in following dependency so, add this in your build.gradle
as dependency.
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
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'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With