Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol 'SCOPE_FILE'

I'm new to app development, and I'm working with Android Studio 3.1.4. I'm working with the Google APIs for sign-in, which have worked well when getting the user's ID, email address, and basic profile. However, I'm now trying to get the Google Drive API working, and I've been stuck for almost two days on this one nagging problem, which is the first step in getting this API to work. Here is the code that's being problematic.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestScopes(Drive.SCOPE_FILE)
            .build();

For some reason, SCOPE_FILE is showing up red and I get a tool tip that reads, "Cannot resolve symbol 'SCOPE_FILE'" when I hover over it. Based on everything that I've read, this should not be an issue. I've tried restarting Android Studio and my computer several times. I upgraded to the most recent version of Android Studio and the most recent version of Gradle. I'm pretty sure I've imported all the necessary classes, which are listed here:

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.Scope;
import com.google.api.services.drive.Drive;
import com.google.android.gms.tasks.Task;

import java.util.HashSet;
import java.util.Set;

I feel as though this must be a simple issue with a simple solution, but I can't figure it out. What am I missing?

like image 282
Halamazoo Avatar asked Aug 16 '26 01:08

Halamazoo


1 Answers

The problem is that you are importing the wrong Drive class, which does not have the SCOPE_FILE field. The solution is to

import com.google.android.gms.drive.Drive;

instead of

import com.google.api.services.drive.Drive;
like image 195
leonardkraemer Avatar answered Aug 18 '26 15:08

leonardkraemer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!