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( "com.app.package", PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("KeyHash", "KeyHash:"+ Base64.encodeToString(md.digest(), Base64.DEFAULT)); 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 hashes"
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 "com.app.package.views
" 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?
Go to the Facebook Developer site. Log into Facebook and, using the dropdown menu in the top-right, go to Developer Settings: In your developer settings, select Sample App from the menu, and add and save your key hash into your profile: You can add multiple key hashes if you develop with multiple machines.
After getting the SHA1 you have to open a link tomeko.net where you will see the option to insert SHA1 and it will convert your SHA1 into Key Hash. This is a 100% recommended solution for the KeyHash but if you are still facing the issue then please let me know in the comment below. Hope you liked it.
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/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With