Cannot resolve import com.google.api.client.json.gson.GsonFactory

Ojonugwa Jude Ochalifu picture Ojonugwa Jude Ochalifu · Apr 25, 2015 · Viewed 14k times · Source

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.

Answer

BrendanBenting picture BrendanBenting · May 9, 2015

You need to use this library:

compile 'com.google.http-client:google-http-client-gson:1.19.0'