简体   繁体   中英

sign in always returns null

I am trying to enable to google sign-in in my app.
I have saved my app in 2 folders (Folder1 (personal) and Folder2 (work)).

In Folder1, it works perfectly fine.
I sign in using " GoogleSignIn.getAccountForExtension ".
I check if I logged in with " GoogleSignIn.getLastSignedInAccount(this) ". It returns TRUE


public void requestGoogleFitPermission() {

        GoogleSignInAccount account = GoogleSignIn.getAccountForExtension(this, fitnessOptions);
        GoogleSignIn.requestPermissions(
                this,
                GOOGLE_FIT_PERMISSIONS_REQUEST_CODE,
                account,
                fitnessOptions);

        Boolean sign = isSignedIn();
        Log.v("signed in???", String.valueOf(sign));   //returns TRUE

    }


private boolean isSignedIn() {
        return GoogleSignIn.getLastSignedInAccount(this) != null;
    }

Now when I try the EXACT same thing in Folder2 it doesn't work correctly.
I get the sign-in pop up and I choose my account.
But for some reason it doesn't retain the account.
When I call " GoogleSignIn.getLastSignedInAccount(this) " its always NULL.

public void requestGoogleFitPermission() {

        GoogleSignInAccount account = GoogleSignIn.getAccountForExtension(this, fitnessOptions);
        GoogleSignIn.requestPermissions(
                this,
                GOOGLE_FIT_PERMISSIONS_REQUEST_CODE,
                account,
                fitnessOptions);

        Boolean sign = isSignedIn();
        Log.v("signed in???", String.valueOf(sign));   //returns FALSE

    }


private boolean isSignedIn() {
        return GoogleSignIn.getLastSignedInAccount(this) != null;
    }

I can see that in the working case the google account gets stored in "zzq.class"

在此处输入图像描述

but is null for the other folder

在此处输入图像描述

Why does this happen?? What should I check?? Scratching my head for hours on this. Any input is really appreciated.

I'd say it happens because in your firebase console you just have only one project, try to create a new project on firebase, link that new project (the one that is not assigned to the one you are using I'd say the one is in FOLDER2) and try it again, it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM