skip to Main Content

I am trying to use facebook api for login on my android application. After following the tutorials I was able to get the confirmation screen after clicking login by facebook button. But when i run my application second time I get “Facebook key hash does not match any stored key hashes” error.

I follow other posts on stackoverflow, deleted my application and created once again etc. but on second run I again get the same error.

Facebook key hash does not match any stored key hashes

Do you know what can be wrong and why I do not get on first run but I get this error on second run?

2

Answers


  1. try this:

     public void Get_hash_key() {
            PackageInfo info;
            try {
                info = getPackageManager().getPackageInfo("your_package_name", PackageManager.GET_SIGNATURES);
                for (Signature signature : info.signatures) {
                    MessageDigest md;
                    md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    String something = new String(Base64.encode(md.digest(), 0));
                    //String something = new String(Base64.encodeBytes(md.digest()));
                    Log.e("hash key", something);
                }
            } catch (PackageManager.NameNotFoundException e1) {
                Log.e("name not found", e1.toString());
            } catch (NoSuchAlgorithmException e) {
                Log.e("no such an algorithm", e.toString());
            } catch (Exception e) {
                Log.e("exception", e.toString());
            }
        }
    

    add your package name and call this function in onCreate() of your Mainactivity

    it will print the Hash key on logcat…

    copy and paste the key on developer panel ,remove other keys

    Login or Signup to reply.
  2. Create a valid keystore to your android app:

    (Windows)

    keytool -genkey -v -keystore fisherbook.keystore -alias fisherbook -keyalg RSA -keysize 2048 -validity 10000
    

    Generate facebook hash key:

    (Windows)

    keytool -exportcert -alias <KEYSTORE_ALIAS> -keystore <COMPLETE_KEYSTORE_PATH> | openssl sha1 -binary | openssl base64 
    

    Or look at facebook error: “Invalid key hash. The key does not match any store hashes…”
    There is your facebook hash key!

    Then put your hash at app/settings (android) at facebook developer website.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search