Home » Android » Android app Key Hash doesn't match any stored key hashes

Android app Key Hash doesn't match any stored key hashes

Posted by: admin April 23, 2020 Leave a comment


I have an application on production on Play Store which uses a login with the Facebook SDK.
When I debug the application from Eclipse there is no problem, but when its on production it gives me the following error after Facebook asks me for the permissions.
I have added on my app page on developers.facebook.com the key hash generated with keytool using this command:

keytool -exportcert -alias diego -keystore
“C:\Users\Diego\Desktop\CeluChat.KeyStore” |
“C:\openssl\bin\openssl.exe” sha1 -binary |
“C:\openssl\bin\openssl.exe” base64

CeluChat.KeyStore is the keystore I used when I exported the signed application, and when keytool promts me for the password, I entered the same when exported.

But the error that gives me on production (downloaded from Play Store) is:

10-20 22:21:10.752: W/fb4a(:):BlueServiceQueue(5872):
com.facebook.http.protocol.ApiException: Key hash
VQ3XhZb5_tBH9oGe2WW32DDdNS0 does not match any stored key hashes.

The Key Hash that is on the exception is different from the key hash generated with keytool. Anyway I added the Key Hash on Facebook, but it is still not working.

How to&Answers:

Facebook some how replaces +,- and / with _

So just try replacing _ with +, – and / and add that hash-key.

Hopefully it should work.


I used this to show the key when I ran my app. In my case, I was getting the incorrect key hash from the keytool command. Notice that if you enter the wrong password(purposely), instead of receiving an error an incorrect key is generated. Use this to get the correct hash and see if it matches the one the in the error log

try {
        PackageInfo info =     getPackageManager().getPackageInfo("com.package.mypackage",     PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT);
            Log.e("MY KEY HASH:", sign);
            Toast.makeText(getApplicationContext(),sign,     Toast.LENGTH_LONG).show();
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {

Also, if for some reason the above method does not work. Try using this APK to generate the correct key hash. Remember that you have to sign it with whatever certificate you are trying to retrieve(debug or release). Install it on your testing device, and run it.



I just discovered a bug with the Sample App key entry page: If you paste a hash key from the app without hitting Enter, and then click the “Save Changes” button, the newly entered code will disappear but the page will show a “Saved!” response message. This isn’t true: it didn’t save. You must hit the Enter key after pasting the hash key and then hit “Save Changes”.

I saved a key including the trailing = character. That worked.


Simple put the returned error message hash key:

10-20 22:21:10.752: W/fb4a(:):BlueServiceQueue(5872): com.facebook.http.protocol.ApiException: Key hash VQ3XhZb5_tBH9oGe2WW32DDdNS0 does not match any stored key hashes.


On Facebook developers key hashes of your app.

Hope this help.


Well, If u r using Windows use this command in cmd .

Move to C:\Program Files\Java\jdk1.8.0_25\bin

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | "C:\openssl\bin\openssl.exe" sha1 -binary | "C:\openssl\bin\openssl.exe" base64

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

This is the solution.


It is a nice question. And there are 2 ways to go about it. What usually happens with us is while integrating Facebook SDK for android, we go on following instructions from the Developer site of facebook.

But once the app is out in the play-store, we tend to forget a procedure that still is pending. And we end upon same error :

05-13 14:45:43.882: W/fb4a(:<default>):BlueServiceQueue(25454): Exception during service
05-13 14:45:43.882: W/fb4a(:<default>):BlueServiceQueue(25454): com.facebook.http.protocol.ApiException: Key hash XXXXXXXXXXXXXX does not match any stored key hashes.

Jus got a checklist for this:

1) Using debug Key, while developing the App

The Facebook developer site is quite helpful with this. Just copy paste the code they have in the Getting started page into your command prompt. viz:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

The password to it is android and you will get the debug key following it.

enter image description here

2) Generating Debug Key, after signing the application

Once the application is ready to be uploaded to the Google Play store, we need to sign it using a key, value of which is generated from the key store. Which is explained well by Satheesh in his answer. using :

keytool -exportcert -alias <Alias Name here> -keystore <Path to keystore> | openssl sha1 -binary | openssl base64

Which gives you a different key, than the debug key.

enter image description here


Please follow below method to generate hash key this is suggested by @lucianbase at this page https://github.com/AntonioCuevaUrraco/nativescript-facebook-login/issues/14

Generate SHA1 key of your app either using android studio or cmd tool.
copy it
like this CD:A1:EA:A3:5C:5C:68:FB:FA:0A:6B:E5:5A:72:64:DD:26:8D:44:84
and open http://tomeko.net/online_tools/hex_to_base64.php to convert your SHA1 value to base64.
This is what Facebook requires
get the generated hash ” ********************= ” and copy the key hash to the facebook app.


After trying all the above i tried this.. and worked!!!

  1. Copy the key hash was the same that Facebook gives on the exception,
  2. Replace "_" with "/" and adding a "=" on the end,
  3. Add it to Facebook
  4. Also check the package name and activity name once again.
    This worked for me!!.


Just Replace The Error Key Hash Within Your https://developers.facebook.com/app application…!

100 Percentage It Will Work For Sure.



well the actually best and easy way is like this. if you see that problem on your phone screen. You should see that problem with android studio LOGCAT. it will like this

01-26 14:58:22.885 14851-19534/? W/fb4a.BlueServiceQueue: Exception during service
                                                          X.1xO: [code] 404 [message]: Key hash 961x8mIbWmA7TRRpbk...= does not match any stored key hashes. (404) [extra]: null
                                                              at X.0fG.D(:240135)
                                                              at X.0k8.F(:255078)
                                                              at X.3gX.EUB(:738232)
                                                              at X.0fo.handleResponse(:242693)
                                                              at X.0k5.run(:254998)
                                                              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
                                                              at X.0NH.run(:187661)
                                                              at X.0JQ.run(:49671)
                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                              at X.0NM.run(:187873)
                                                              at java.lang.Thread.run(Thread.java:761)

copy this hash key from logcat which is I had made it private (…) and paste it to your facebook developer page. It will solve your problem immediately. Also be ensure that your released APK’s hash key different from the original hash key which is download from google play.


Enable Single Sign On
Enable single sign on for your app by setting Single Sign On to Yes below. please check point no. 9 on https://developers.facebook.com/docs/facebook-login/android