Facebook key hash does not match any stored key ha

2019-01-04 08:37发布

I'm really having troubles with the Facebook hash key. I generated it in my Eclipse.. proof:

Then I went to https://developers.facebook.com/ and registered a new app.

And finally I've set my hashkey at the settings of Facebook developers:

But no whatter I do I keep getting the same error log: "Key hash B5dWUEYfZJL/...........jyA= does not match any stored key hashes"

Does anybody know what I did wrong or how I can fix this problem? If I used the id and name from the HelloFacebookSample inside my own app everything works. So it HAS to do with the key hash, id or name I've set somewhere most likely..

Thank you, Yenthe

14条回答
劳资没心,怎么记你
2楼-- · 2019-01-04 08:48

Using Debug key store including android's debug.keystore present in .android folder was generating a strange problem; the log-in using facebook login button on android app would happen perfectly as desired for the first time. But when ever I Logged out and tried logging in, it would throw up an error saying: This app has no android key hashes configured. Please go to http:// ....

Creating a Keystore using keytool command(keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 10000) and putting this keystore in my projects topmost parent folder and making a following entry in projects build.gradle file solved the issue:

 signingConfigs {
        release {
            storeFile file("my-release-key.keystore")
            storePassword "passpass"
            keyAlias "alias_name"
            keyPassword "passpass"
        }    }

Please note that you always use the following method inside onCreate() of your android activity to get the key hash value(to register in developer.facebook.com site of your app) instead of using command line to generate hash value as command line in some cased may out put a wrong key hash:

    public  void showHashKey(Context context) {
        try {
            PackageInfo info = context.getPackageManager().getPackageInfo("com.superreceptionist",
                    PackageManager.GET_SIGNATURES);
            for (android.content.pm.Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());

                 String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT);
                Log.e("KeyHash:", sign);
                //  Toast.makeText(getApplicationContext(),sign,     Toast.LENGTH_LONG).show();
            }
            Log.d("KeyHash:", "****------------***");
        } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
e.printStackTrace();
        }
    }
查看更多
对你真心纯属浪费
3楼-- · 2019-01-04 08:50

I got the same problem. I found that I used wrong hashkey. keytool printed wrong hashkey because I run command with wrong alias.
Please check your command again.It will resolve your issue

keytool -exportcert -alias "test fb sdk" -storepass android -keypass android -keystore "C:\keystore.keystore" | openssl sha1 -binary | openssl base64
查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-04 08:52

I encountered a similar problem. The solution is surprisingly simple.

The error message looks like this:

07-05 ...... Invalid key hash. The key hash sL1***************VY= does not match any stored key hashes. Configure your app key hashes at http://developers.facebook.com/apps/150*******778
07-05 ......     at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:191)

Simply log into https://developers.facebook.com , select the "Settings" tab, and add the key hash "sL1***************VY=" to the list of saved Key hashes in the Android panel.

查看更多
看我几分像从前
5楼-- · 2019-01-04 08:55

"Enabled Single Sign On for Your App" that's why it work only one time. please go to developer.facebook and check settings.it work for me

查看更多
趁早两清
6楼-- · 2019-01-04 08:56

Check your google-services.json . May be it is different one. Download your latest google-services.json and then run the app. Hope it helps.

查看更多
我命由我不由天
7楼-- · 2019-01-04 08:58

This is a case that could have possibly occurred and what solved my error:

In the https://developers.facebook.com/quickstarts after you run

OSX/Linux:

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

Windows:

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

When Enter keystore password: is asked you may have accidentally typed a wrong password, the default password is "android". Typing any other password will give you a different/wrong hash key. Paste the correct hash key in the Key Hashes field on your app page

This solved my problem, hope this helps whoever made this particular error that I made

查看更多
登录 后发表回答