Facebook的Android应用程序错误:无效的密钥哈希 [英] Facebook android app error : Invalid key hash
问题描述
我已经将Facebook SDK导入到我的android项目中,第一次从我的android应用程序登录到Facebook,但第二次出现此错误:
< blockquote>
密钥散列无效。密钥哈希...与任何存储的密钥
散列不匹配。在
配置您的应用程序密钥哈希 http://developers.facebook.com/apps/ ..
我也尝试输入他们在这个错误中提供的密钥,但它不起作用。
编辑:
我已经使用了cmd命令,它会生成一个密钥并要求输入密码为android
据我所知,你已经得到了你的密钥哈希,但我仍然会在这里把代码放在控制台中。
PackageInfo info;
尝试{
info = getPackageManager()。getPackageInfo(com.your.project.package,PackageManager.GET_SIGNATURES);
(签名签名: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());
}
其中com.your.project.package
是你的项目包)=
接下来的事情,不要删除以前的关键哈希,他们不会发生冲突,我认为。例如,我在我的Facebook应用程序中有2个keyhashes。
最新的事情,我认为这是问题所在。在developers.facebook上转到您的应用的状态和审查。并将您的应用程序切换到公共。
I have imported the Facebook SDK to my android project, first time I logged in to Facebook from my android application it worked, but the second time I got this error :
Invalid key hash. The key hash "..." does not match any stored key hashes. Configure your app key hashes at http://developers.facebook.com/apps/..
I also tried to enter the key they provided in this error but it didn't work.
EDIT: I have used the cmd command to which it generates a key and asks for the password which is "android"
As I understand you've got your key hash, but still I'll put here the code for getting it in the console.
PackageInfo info;
try {
info = getPackageManager().getPackageInfo("com.your.project.package", 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());
}
Where "com.your.project.package"
is the package of your project =)
Next thing, dont delete previous key hash, they don't conflict I think. For example I have 2 keyhashes in my facebook app.
And the latest thing, and I think this is the problem. Go to the Status&Review of your app at the developers.facebook. And switch your application to public.
这篇关于Facebook的Android应用程序错误:无效的密钥哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!