Android Facebook SDK: Key hash does not match any stored key hashes when uploading google play

时光总嘲笑我的痴心妄想 提交于 2019-11-28 16:44:46
Ramon Vicente

You followed the steps that facebook provides for the creation of a login application?

You need a 'Production keyhash' obtained starting your release keystore:

From comand line:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

And add this key on facebook app page options.

More information: Facebook docs

Milk Man

I spent a full day trying to figure out why this wasn't working...

When generating the hash key for production you need to use openssl-0.9.8e_X64.zip on windows, you cannot use openssl-0.9.8k_X64.zip

The versions produce different hash keys, for some reason 9.8k does not work correctly... 9.8e does

Reference

This was giving the wrong key for me.

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

A workaround that worked for me was: 1. Put this code in your launching activity

private void printKeyHash(){
    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "YOUR_PACKAGE_NAME", 
                PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
    } catch (NameNotFoundException e) {
        Log.d("KeyHash:", e.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.d("KeyHash:", e.toString());
    }
}
  1. Export the app for publishing on play store using the .keyStore
  2. Install the app before uploading to play store and run it and note the keyHash printed.
  3. Add the keyHash to the Facebook App.

Hope this helps someone.

You can also just take the missing hash from the stack trace of the ApiException: Key hash XXXXXXX does not match any stored key hashes. There you have it already, only missing the =at the end. So take XXXXXXX=.

This is working fine to me

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

Where <RELEASE_KEY_ALIAS>is your Alias name while you create signed application.

And <RELEASE_KEY_PATH>is Location in the below picture And then enter the password is key create password in the below picture instead of android

Above solutions are correct to a point. But if someone still faces an issue . Delete the key from developer profile and add it again writing= at the end and press enter . You have to add key in both settings and developer.

I was facing issues with app release to google play and using release key

I solved the issue in the simple way..

1)Frist Logout from the FaceBook app.

2)Open the Appplication which you have developed when cilck to login it will show the haskkey not mathcing.

3)Generate the SHA1 signing report in (Right Side Tab android studio) Gradle-->Task-->android->signing Report .(HEXA String)

4)Convert that to base 64.(Link) 5)Copy the output and past in the FaceBook developer page..


kshitij

please check point no. 9 on Enable Single Sign On for Your App

Enable Single Sign On Enable single sign on for your app by setting Single Sign On to Yes below. YesNo Single Sign On

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!