Add compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' to your build.gradle file and get the dependency resolved or add corresponding jars to your bulid path.
then use GsonConverterFactory.create() to get the Converter Factory
I tried using 2.0.0-beta1 but it gave me an illegal type conversion error for factory as given below, so moved to 2.0.0-beta2
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
So my suggestion is to use 2.0.0-beta2
my build.gradle has following dependencies to resolve retrofit.
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
Answer from manoj on Stack OverflowAdd compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' to your build.gradle file and get the dependency resolved or add corresponding jars to your bulid path.
then use GsonConverterFactory.create() to get the Converter Factory
I tried using 2.0.0-beta1 but it gave me an illegal type conversion error for factory as given below, so moved to 2.0.0-beta2
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
So my suggestion is to use 2.0.0-beta2
my build.gradle has following dependencies to resolve retrofit.
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
If you are using retrofit 2, you need to include the convert-gson package. For gradle builds, you can add compile 'com.squareup.retrofit:converter-gson:2.0.0-beta3' to your dependencies section.
For other build systems, or to download the jar, checkout the Maven Central convert-gson page.
Add compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' to your build.gradle file and get the dependency resolved or add corresponding jars to your bulid path.
then use GsonConverterFactory.create() to get the Converter Factory
I tried using 2.0.0-beta1 but it gave me an illegal type conversion error for factory as given below, so moved to 2.0.0-beta2
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
So my suggestion is to use 2.0.0-beta2
my build.gradle has following dependencies to resolve retrofit.
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
Answer from manoj on Stack OverflowEDIT
retrofit 2 is now stable. Use
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
in your build.gradle dependency section
old answer
with Retrofit 2.0 you have to declare in your build.gradle the convert factory you want to use. Add
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
to your gradle and sync it again
From another article on that site
Retrofit 2 doesn’t ship with Gson by default. Before, you didn’t need to worry about any integrated converter and you could use Gson out of the box. This library change affects your app and you need to import a converter as a sibling package as well. We’ll touch the converter later within this post and show you how to config the Gson or any other response converter for your app.
Thus, add this to your build.gradle
dependencies {
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}
Add following dependency to build.gradle:
implementation 'com.google.code.gson:gson:2.11.0'
Or download the JAR file from Maven by clicking a release and finding the .jar file.
Replace 2.8.7 with the latest version from Maven.
Visit the GitHub repo for documentation and more.
Read Google-gson
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.
Add the following line to your MODULE LEVEL build.gradle configuration:
dependencies {
implementation 'com.google.code.gson:gson:2.11.0'
}