Android Facebook SDK: generate release key hash

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: https://developers.facebook.com/docs/android/getting-started/


For future reference, if you already have your app on Play Store you can this:

  1. Go to Release Management

  2. select App Signing in Release Management

  3. You can see SHA1 key in hex format App signing certificate.

  4. Copy the SHA1 in hex format and convert it in to base64 format, you can use this link http://tomeko.net/online_tools/hex_to_base64.php to do that without the SHA1: part of the hex.

  5. Go to Facebook developer console and add the key(after convert to base 64) in the settings —> basic –> key hashes.


The simplest solution.

1) Sign your Apk.

2) Connect your device to machine and Install signed apk on real device.

3) When facebook login is pressed, you will get an error saying "Invalid key hash. The key hash "xxx" does not match any stored key. ..." on your logcat.

4)Copy the logcat Hash Key and put this key to developers.facebook.com/apps/104...../settings/


I find a solution. for MAC

Use this one to get YOUR_RELEASE_KEY_ALIAS:

keytool -list -keystore /Users/***/Documents/keystore/***.jks

and this one to get your release keyhash:

keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore /Users/***/Documents/keystore/***.jks | openssl sha1 -binary | openssl base64

It works for me.