Google Login failed in Android Studio

Viewed 246

Google Login failed in Android Studio

I'm using firebase to use Google Login service and there's an error about Android Studio. I think it's fingerprint problem. I had reapplied google-services.json with new fingerprints but I still couldn't do it. Here's my code. I already entered my debug and release SHA1 key to firebase console.

    Button btGoogle = (Button)findViewById(R.id.btGoogle);
            btGoogle.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent signInIntent = googleSignInClient.getSignInIntent();
                    signInLauncher.launch(signInIntent);
                }
            });

signInLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
            @Override
            public void onActivityResult(ActivityResult result) {
                // 현재 result.getResultCode() == Activity.RESULT_CANCELED로 리턴
                if (result.getResultCode() == Activity.RESULT_OK) {
                    Intent data = result.getData();

                    Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
                    try {
                        // Google Sign In was successful, authenticate with Firebase
                        GoogleSignInAccount account = task.getResult(ApiException.class);
                        Log.d("LoginActivity", "firebaseAuthWithGoogle: " + account.getId());
                        resultLogin(account.getIdToken());
                    } catch (ApiException e) {
                        // Google Sign In failed, update UI appropriately
                        Log.w("LoginActivity", "Google sign in failed", e);
                    }
                }
            }
        });

p.s. I used ActivityResultLauncher instead of startActivityForResult because startActivityForResult had been deprecated.

0 Answers
Related