-1

I'm using firebase ui in my app for login. everything works fine when i run it in debug mode - no errors at all. I'm running it through my cellphone and it works fine!

My problem starts when i upload my app to play store. When a user try to log in with facebook it tells the user that the hash key does not match to any stored hashes. I checked few times in Facebook Developers and in my Android Studio and its the same hash key.

I also have "Developer error" when i try to log in with Google. I have no idea why...

And also Error login with "Email and password" - the user enter his email and password and nothing happens. Its just stay on the same activity.

I'm not sure what should i do, should i create release SHA-1? or its something else that im missing here.

Here is my login code

        public void startSignIn(){
    List<AuthUI.IdpConfig> providers = Arrays.asList(
            new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER)
                    .setPermissions(Arrays.asList(Scopes.PROFILE,Scopes.EMAIL)).build(),
            new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
            new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build());
    Intent intent = AuthUI.getInstance()
            .createSignInIntentBuilder()
            .setAvailableProviders(providers).build();
    startActivityForResult(intent,RC_SIGN_IN);
}


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

    if(requestCode == RC_SIGN_IN){
        IdpResponse idpResponse = IdpResponse.fromResultIntent(data);
        if(idpResponse != null && resultCode == RESULT_OK){
            currentUser = FirebaseAuth.getInstance().getCurrentUser();

            //check if the user is exists by userUID. if he is, it jumps to main activity
            refToUsers.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    if(dataSnapshot.hasChild(currentUser.getUid())){

                        Intent mainActivity = new Intent(getApplicationContext(), MainActivity.class);
                        mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(mainActivity);
                    }else{
                        //if the user is not exists it will move to register activity
                        Intent registerActivity = new Intent(getApplicationContext(), RegisterActivity.class);
                        registerActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(registerActivity);
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.d(TAG,databaseError.getMessage());
                }
            });



        }else if (idpResponse.getErrorCode() == ErrorCodes.NO_NETWORK) {
            errorToast("No internet connection");

        }else if (idpResponse.getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
            errorToast("Unknown Error");
        }
    }

Simple code but for some reason not working...

E.Bolandian
  • 453
  • 5
  • 20

1 Answers1

0

When you use the debug mode, the signing key used is for debugging only, it is a debug sign-in key. For published apps, your signing key should be the one used in the Play Console.

If you've published your app successfully to the Play store then you've already generated the required SHA-1 certificate fingerprint. And, yes it is the release-signing key which is required for published apps.

Here's how to get the required signing key from your Google Play Console:

  1. Log into your Google Play Console.
  2. Select your app from the listing.
  3. On the left-hand side menu select "Release Management" with the rocket icon.
  4. Select "App signing" from the expanded "Release Management" menu.
  5. In the "App signing certificate" section you will see the SHA1, SHA256 and MD5 certificate fingerprints. Copy the one you need and use it.

You will also need to add this SHA1 fingerprint to your Firebase Console:

  1. Log into your Firebase Console.
  2. Select your Firebase Project.
  3. Go to "Project Settings" the gear icon next to your Project Overview button on the left-hand side menu.
  4. In the General tab, scroll down to "Your Apps" section which has the project details listed. You'd have had to download the google-services.json from here earlier.
  5. Add your release SHA1 fingerprint here.
  6. Download a fresh copy of the google-services.json file.
  7. Use this newer json file with your project instead of the older one, as you've changed Firebase configuration and will need to recompile the app.

Hope this helps.

Useful Links:

https://developer.android.com/studio/publish/app-signing

How to enable Google Play App Signing

MD Naseem Ashraf
  • 1,003
  • 2
  • 8
  • 19