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

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


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


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.