javaandroidandroid-facebook

Can not sign in with Google and Facebook with Release Apk


I am working with android application which contain sign in with google and sign in with Facebook , in the debugging mode both worked fine but after making release Apk and upload it to play store , both of Facebook and Google does not work . I did the Following steps : 1-i generate my new certificate fingerprint for release Apk and replace the old one in Facebook developer and making new Google App with new certificate fingerprint but also that did not work for me . this is Facebook login part

 //facebook part
    callbackManager = CallbackManager.Factory.create();
    loginButton= (LoginButton)findViewById(R.id.login_button);
    loginButton.setReadPermissions(Arrays.asList("email", "user_photos", "public_profile"));
    loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id, first_name, last_name, email,gender, birthday, location"); // ParĂ¡metros que pedimos a facebook
            //  Toast.makeText(getApplicationContext(),""+loginResult.getAccessToken(),Toast.LENGTH_SHORT).show();
            final String accessToken = loginResult.getAccessToken().getToken();
            GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object, GraphResponse response) {
                    Log.i("LoginActivity", response.toString());
                    // Get facebook data from login
                    try {
                        String FaceEmail= (String)object.get("email");
                        object.get("gender");
                        if(accessToken!=null)
                        {
                            if(isNetworkAvailable()) {
                                checkEmail(accessToken, "f");
                            }

                        }
                        else
                        {
                            Toast.makeText(MainActivity.this,"Please try another method to login ",Toast.LENGTH_SHORT).show();
                        }

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

but always i got an exception "Invalid hash key"

and this is Google login part

public void signIn ()
{   Intent intent =Auth.GoogleSignInApi.getSignInIntent(googleApiClient);}
  public void handleResult (GoogleSignInResult result)
{
    if (result.isSuccess()) {
        GoogleSignInAccount account = result.getSignInAccount();
        String email = account.getEmail();
        if(email!=null) {
            upateUI(true,email);
        }
        else
        {
            upateUI(false,"");
        }
    }
    else
        upateUI(false,"");

}

Note that i made my google app and Upload my Signed Apk from different Accounts. does this make any problem? So what can i do?


Solution

  • this worked for me : i got into play console and found two certificates fingerprint the first one which make google work with release Apk and the second is the certificates fingerprint for my keystore