MikeKeepsOnShine MikeKeepsOnShine - 1 year ago 282
Android Question

Android Facebook SDK: generate release key hash

I'm building an app in which users can log in with Facebook.

I've created the hash keys like following:

try {
PackageInfo info = getPackageManager().getPackageInfo(
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
Log.d("KeyHash", "KeyHash:"+ Base64.encodeToString(md.digest(),
Toast.makeText(getApplicationContext(), Base64.encodeToString(md.digest(),
Base64.DEFAULT), Toast.LENGTH_LONG).show();
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {


In debug mode, everything works well.

When i export the project for release, it gives this error:

"Invalid key hash. The key hash ****************** does not match any stored key ashes etcc"

I paste the key printed in the Facebook Developer dashboard, but the application still gives me that error.

The complete package of my actvity is "
" and i tried to use this package (as Google Play Package Name) in the dashboard, but nothing changed.

How can I solve it? How can I generate the right release key hash?

Answer Source

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/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download