与Facebook的Andr​​oid SDK无效的密钥哈希 [英] Invalid Key hash with Facebook Android SDK

查看:156
本文介绍了与Facebook的Andr​​oid SDK无效的密钥哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图利用Facebook的Andr​​oid SDK开发与Facebook的登录按钮一个简单的应用程序。 但我有带钥匙哈希麻烦。我创建了两个调试键和释放键:

I'm trying to use Facebook Android SDK to develop a simple app with the Facebook Login Button. But i'm having trouble with Key Hashes. I've created both a debug key and a release key:

调试键:

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

释放键:

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

然后我复制了Facebook的开发者页面这关键的哈希值。 当我出口的apk文件,并将其复制到它运作良好的设备,但是当我尝试安装Eclipse中的应用程序(如/调试的Andr​​oid应用程序运行),这是行不通的。看来这个应用程序是使用来自一个我所用密钥工具创建一个不同的密钥散列。 任何人都知道如何解决这个问题呢?

And then i copied this key hashes in the Facebook Developers page. When i export the apk and copy it into the device it works well, but when i try to install the app from Eclipse (run as/debug as Android Application) it doesn't work. It seems that the app is using a different key hash from the one i've created with keytool. Anyone knows how to solve this problem?

推荐答案

尝试从这里得到HashKey

Try to get the HashKey from here

public static void showHashKey(Context context) {
            try {
                PackageInfo info = context.getPackageManager().getPackageInfo(
                        "com.example.tryitonjewelry", PackageManager.GET_SIGNATURES); //Your            package name here
                for (Signature signature : info.signatures) {
                    MessageDigest md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    Log.i("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
                    }
            } catch (NameNotFoundException e) {
            } catch (NoSuchAlgorithmException e) {
            }
        }

这篇关于与Facebook的Andr​​oid SDK无效的密钥哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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