Home » Android » android – invalid key hash the key hash does not match any stored key hash

android – invalid key hash the key hash does not match any stored key hash

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have created a app on facebook. I have added keyhash properly and app was running fine but when i came today and try to run it again it gives me this error. enter image description here

This is second time it happens. Previsouly when i get this error i removed the app and add it again and it starts working again and offcourse i can’t do it again and again.

One more thing, the key hash he mentioned in the error is not the same i added in the app and if i go to app setting the key hash is correct there.

How to&Answers:

delete the app and try to create a new hash key by following this
method!

Answer:

There is no need to delete app from Facebook developer website again and again.
What all you need is to go your terminal(Mac or Linux) and type:

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

And Window’s user open cmd and type:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl
base64

After this you will be asked for “Enter keystore password:”, for this remember enter only android .Now use this key hash at Facebook developer website(Note: this key hash will be same as key hash you were getting in error).
Mostly people are asking to delete app from Facebook developer website and again make new one,but believe me this is actually what you have to do.

Answer:

Use one of this versions: openssl-0.9.8e _X64.zip

You should not use the openssl-0.9.8k_X64.zip.

difference is k and e

and generate key again using
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64 on cmd

Answer:

You have to do following step again:-

  1. Delete application on the website of Facebook (developers.facebook.com)
  2. Delete the file debug.keystore.
  3. Generate a new key (by running your app again)
  4. Create a new app on developers.facebook.com and add the new hash key
  5. Re-run your app
  6. Succes!

and more info see below link:-

https://developers.facebook.com/docs/android/getting-started/

Answer:

Add the code below to the onCreate() :
*Don’t forget to change the package name.

try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.yours.package", 
            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) {

} catch (NoSuchAlgorithmException e) {

}

Source: https://developers.facebook.com/docs/android/getting-started/

Answer:

Only one reason of this error which Hash key different for every development environment its mean that if you are working on different machines every PC/Mac will generate its own Hash Key.

NOW SOLUTION:

IN two Simple step you can fix this error just write hash key in your Facebook Developer account like attached images:

First Step: you will see here HASH KEY note hat key and then follow next step
enter image description here

Last Step: write down copied hash key in Key Hashes field. like
enter image description here

No need to delete or reconfigure app.

Thanks.

Answer:

Hi In my case it was the issue with generating the release key for the production. Releasing the apk to play store requires you to generate the release key.
Visit this link by Facebook for detailed information.

Answer:

In my case, I had changed the package name AFTER creating the private key, so, key hash was wrong/invalid.