2

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.

Jalim
  • 45
  • 6
  • 2
    What's the code error message? Is it [code10](https://stackoverflow.com/questions/51360250/firebase-ui-authentication-with-google-fails-with-message-code10-message10/51360406)? Besides that, I think the following [article](https://medium.com/firebase-tips-tricks/how-to-create-a-clean-firebase-authentication-using-mvvm-37f9b8eb7336), might help. Or if you understand Kotlin, most likely [this](https://medium.com/firebase-tips-tricks/how-to-handle-firebase-authentication-in-clean-architecture-using-jetpack-compose-e9929c0e31f8). – Alex Mamo Dec 23 '21 at 06:51
  • 2
    @AlexMamo Thanks for your fast answer. I have to ask our coding club members about our error code. (Maybe ApiException or something like that) I will check your articles. – Jalim Dec 23 '21 at 06:57
  • @AlexMamo The thing here is that there isn't any specific error code given, which is wierd. Logcat shows me that `Channel {0} was not shutdown properly!!!` but I can't find any more error messages related to this issue. The full message is on GitHub Issues: https://github.com/AppDevelopers2021/androidStudia/issues/6 (Oh, and I'm in this coding club as well) – Jongwoo Lee Dec 23 '21 at 07:45

0 Answers0