Am trying to use the GsonFactory
class in my app:
StudentApi.Builder builder = new StudentApi.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), null);
but it says cannot resolve symbol 'GsonFactory'
I have the import in my class
import com.google.api.client.json.gson.GsonFactory;
but gson
couldn't be resolved so I tried Alt-Enter - Find jar on web
but the library couldn't be found.
I have this in my build.gradle
dependencies:
dependencies {
...
compile 'com.google.code.gson:gson:2.3'
compile 'com.google.api-client:google-api-client-android:1.19.0'
}
I can confirm that this class does exist.
In your gradle.build you need to add:
compile ('com.google.http-client:google-http-client-gson:1.19.0') {
exclude module: 'httpclient'
}
after
compile('com.google.http-client:google-http-client-android:1.19.0') {
exclude(group: 'com.google.android', module: 'android')
}
After doing so, you will be able to use:
com.google.api.client.json.gson.GsonFactory()
You need to use this library:
compile 'com.google.http-client:google-http-client-gson:1.19.0'
GsonFactory is from the older version.
Now, you should use JacksonFactory.getDefaultInstance()
instead.
Import it like this import com.google.api.client.json.jackson2.JacksonFactory;
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