Android设备上的Android Facebook集成无效密钥哈希错误,但在模拟器上工作正常 [英] Android Facebook Integration Invalid Key hash error on Android device but working fine on Emulator

查看:107
本文介绍了Android设备上的Android Facebook集成无效密钥哈希错误,但在模拟器上工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在android设备上运行我的Android应用程序时,当我第一次单击继续使用Facebook 按钮时,它运行正常.当我注销后再次尝试登录时,它显示错误""Invalid Key has"(无效密钥具有)密钥具有与任何存储的密钥哈希不匹配.我已经重新生成了密钥哈希并替换了Facebook上的新密钥.但是仍然没有得到结果.

When I run my Android app in my android device it was working fine when I clicked first time on Continues with Facebook button.When i try to login again after logged out it is showing an error "Invalid Key has" The key has does not match any stored key hash. I have already regenerated key hash and replaced new key on facebook. bUt still did not get result.

我第一次轻松登录,但是再次退出后,我试图继续使用Facebook ,但它显示一条错误消息"Invalid Key has":

First time I had easily logged-in, But after logged out again I'm trying to Continues with Facebook but it is showing an error message "Invalid Key has":

但是同一应用程序在Emulator上运行得很好.为什么它不能在我的设备上运行?

But the same application is running perfectly fine on Emulator. why it is not working on my devices?

推荐答案

将此代码放入任何可访问的活动的onCreate方法中,以在控制台中打印哈希键,并使用该应用程序更新您的Facebook关联帐户中的哈希键./p>

Hi Put this code in any reachable activity's onCreate method to print the hash key in the console and update that hash key in your facebook linked account with the application.

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

        }

这篇关于Android设备上的Android Facebook集成无效密钥哈希错误,但在模拟器上工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆