2

The app works perfectly fine when running either through emulator or from usb off of android studio. but when i generate a signed APK and run it on a physical device it does not want to sign into Firebase.

I've made sure i had my Release SHA-1 on firebase, updated my google-services.json. 

I've made sure i had my Release SHA-1 on firebase, updated my google-services.json.

void SignInGoogle(){
            progressBar.setVisibility(View.VISIBLE);
                Intent signIntent = mGoogleSignInClient.getSignInIntent();
                startActivityForResult(signIntent,GOOGLE_SIGN);
            }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
            super.onActivityResult(requestCode, resultCode, data);

            if(requestCode == GOOGLE_SIGN) {
                Task<GoogleSignInAccount> task = GoogleSignIn
                        .getSignedInAccountFromIntent(data);

                try{
                    GoogleSignInAccount account = task.getResult(ApiException.class);
                    if(account != null) firebaseAuthWithGoogle(account);

                }catch (ApiException e ){
                    e.printStackTrace();
                }
            }
        }

        private void firebaseAuthWithGoogle(GoogleSignInAccount account) {
            Log.d("Tag","fierbaseAuthWithGoogle : " + account.getId());

            AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(),null);
            mAuth.signInWithCredential(credential)
                    .addOnCompleteListener(this,task -> {
                        if (task.isSuccessful()){
                            progressBar.setVisibility(View.INVISIBLE);
                            Log.d("Tag","Sign in success");
                            Toast.makeText(MainActivity.this, "Sign in success", Toast.LENGTH_SHORT).show();
                            FirebaseUser user = mAuth.getCurrentUser();
                            updateUI(user);

                        }else{
                            progressBar.setVisibility(View.INVISIBLE);
                            Log.d("Tag","Sign in fail");
                            Toast.makeText(MainActivity.this, "Sign in failed", Toast.LENGTH_SHORT).show();
                            updateUI(null);

                        }


                    });
        }
Zoe
  • 27,060
  • 21
  • 118
  • 148

0 Answers0