Cai
Cai

Reputation: 5323

files.get and .getRequestFactory cannot be resolved

I'm trying to get the metadata of a file in my Google Drive through the fileID but I'm running into some problems using files().get and getRequestFactory().

Specifically I'm looking at this and on the sample it shows the line

File file = service.files().get(fileID).execute(); and

HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl())).execute();

I used these:

import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpResponse;
import com.google.api.services.drive.model.File;

as stated in the sample and loaded the com.google.apis:google-api-services-drive:v2-rev168-1.20.0 dependency. But it's still resulting in Cannot resolve method files() and Cannot resolve method getRequestFactory(),

Can anyone shed some light on this?

Upvotes: 1

Views: 740

Answers (1)

seanpj
seanpj

Reputation: 6755

I have recently run my project with these imports / dependencies without problems, try to double-check your situation

import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.http.FileContent;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.api.services.drive.model.File;
import com.google.api.services.drive.model.FileList;
import com.google.api.services.drive.model.ParentReference;

com.google.api.services.drive NEEDS
    com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc
com.google.api.client NEEDS
    com.google.api-client:google-api-client-android:1.20.0
com.google.api.client.json.gson NEEDS
   com.google.http-client:google-http-client-gson:1.20.0

The chunk above is pulled from this GitHub test / demo. You're welcome to use it (replace the GDAA referencies in MainActivity with 'REST').

Good Luck

Upvotes: 5

Related Questions