无效的密钥散列。关键哈希值不匹配任何存储的密钥哈希值的Facebook的Andr​​oid密钥、不匹配、关键、oid

2023-09-07 01:10:26 作者:有梦就要嚼着炫迈去追

我正在开发一个使用Facebook的身份验证的Andr​​oid应用程序。在调试模式下,我使用了code生成的调试密钥散列:

I'm developing an Android application that uses Facebook Authentication. In debug mode, i use the debug key hash generated by the code:

try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "com.org.package", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String sign = Base64
                        .encodeToString(md.digest(), Base64.DEFAULT);

                    Log.e("MY KEY HASH:", sign);

            }
        } catch (NameNotFoundException e) {
        } catch (NoSuchAlgorithmException e) {
        }

现在我要发布我在谷歌Play商店的应用程序,所以我需要生成一个释放键哈希值。我以前在Facebook开发文档中提到的方法是:

Now I want to publish my app in Google play store, so i need to generate a release key hash. I used the method mentioned in facebook developers doc which is:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

对于RELEASE_KEY_PATH它的出口项目的apk时产生的kaystore的路径。

For the RELEASE_KEY_PATH it's the path of kaystore generated when exporting project to apk.

我添加产生的Facebook应用程序哎哈希但我仍然有错误:

I added the hey hash generated to facebook app but i still have the error:

无效的密钥散列。关键哈希值不匹配任何存储的密钥散列Facebook的机器人。

invalid key hash. the key hash does not match any stored key hashes facebook android.

当我添加在Java $ C $生成散列哎c那么它的工作原理,但我不能对每个设备做,我需要发布我的应用程序,这样每个人都可以使用它。

When i add the hey hash generated by java code it works, but i can't do it for each device, i need to publish my app so that every one can use it.

解决方案是什么?请帮帮我。

What is the solution? Please help me.

推荐答案

我已经解决了我的问题:D

I have solved my problem :D

因此​​有释放钥匙散列,您需要安装apk文件在你的Andr​​oid模拟器,并通过以下code生成的密钥添加到您的Facebook应用程序:

So to have the release key hash, you need to install the apk file in your Android emulator, and add the key generated by the following code to your Facebook app:

try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "com.org.package", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String sign = Base64
                        .encodeToString(md.digest(), Base64.DEFAULT);

                    Log.e("MY KEY HASH:", sign);

            }
        } catch (NameNotFoundException e) {
        } catch (NoSuchAlgorithmException e) {
        }

GOOD LUCK !!

Good luck!!