GoogleSignIn.getClient(this, gso) does not exist

Viewed 659

I have problem, when i tried to make google authentication .getClient(this, gso) steel red and alt+enter does not help!

I tried to make the same in new, clear project, but nothing changed(

private void CreateRequestGoogleSignIn() {
        // Configure Google Sign In
        GoogleSignInOptions gso = new GoogleSignInOptions
                .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();

        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
        

    }```
 
3 Answers

Declare mGoogleSignInClient as an object of GoogleSignInClient like this before you initialize it

private lateinit var mGoogleSignInClient: GoogleSignInClient

then you can use it as you did, like mGoogleSignInClient = GoogleSignIn.getClient(this, gso)

Also don't forget to import GoogleSignInClient

import com.google.android.gms.auth.api.signin.GoogleSignInClient

The problem was in this line of code:

mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

and i change this line:

mGoogleSignInClient = com.google.android.gms.auth.api.signin.GoogleSignIn.getClient(this, gso);

Add this dependency in the build gradle

implementation 'com.google.android.gms:play-services-auth:20.2.0'
Related