Android 无效的密钥散列密钥散列不匹配任何存储的密钥散列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24321712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
invalid key hash the key hash does not match any stored key hash
提问by umerk44
I have created a app on facebook. I have added keyhash properly and app was running fine but when i came today and try to run it again it gives me this error.
我在 facebook 上创建了一个应用程序。我已经正确添加了 keyhash 并且应用程序运行良好,但是当我今天来尝试再次运行它时,它给了我这个错误。
This is second time it happens. Previsouly when i get this error i removed the app and add it again and it starts working again and offcourse i can't do it again and again.
这是第二次发生。Previsouly 当我收到此错误时,我删除了该应用程序并再次添加它,它再次开始工作,当然我无法一次又一次地这样做。
One more thing, the key hash he mentioned in the error is not the same i added in the app and if i go to app setting the key hash is correct there.
还有一件事,他在错误中提到的密钥散列与我在应用程序中添加的不同,如果我去应用程序设置,密钥散列在那里是正确的。
采纳答案by Sreejith SP
回答by Rishabh Chandel
There is no need to delete app from Facebook developer website again and again. What all you need is to go your terminal(Mac or Linux) and type:
无需一次又一次地从 Facebook 开发者网站删除应用程序。你所需要的只是去你的终端(Mac 或 Linux)并输入:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
And Window's user open cmd and type:
和 Window 的用户打开 cmd 并键入:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl
base64
After this you will be asked for "Enter keystore password:", for this remember enter only android
.Now use this key hash at Facebook developer website(Note: this key hash will be same as key hash you were getting in error).
Mostly people are asking to delete app from Facebook developer website and again make new one,but believe me this is actually what you have to do.
在此之后,您将被要求输入“输入密钥库密码:”,为此请记住仅输入android
。现在在 Facebook 开发者网站上使用此密钥哈希(注意:此密钥哈希将与您出错的密钥哈希相同)。大多数人要求从 Facebook 开发者网站删除应用程序并重新制作新的应用程序,但相信我,这实际上是您必须做的。
回答by Keyul
Use one of this versions: openssl-0.9.8e _X64.zip
使用以下版本之一: openssl-0.9.8e _X64.zip
You should notuse the openssl-0.9.8k_X64.zip
.
你应该不使用openssl-0.9.8k_X64.zip
。
difference is kand e
差异是k和e
and generate key again using
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
on cmd
并使用keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
cmd再次生成密钥
回答by Alexey
Add the code below to the onCreate() : *Don't forget to change the package name.
将以下代码添加到 onCreate() : *不要忘记更改包名称。
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.yours.package",
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) {
}
Source: https://developers.facebook.com/docs/android/getting-started/
来源:https: //developers.facebook.com/docs/android/getting-started/
回答by duggu
You have to do following step again:-
您必须再次执行以下步骤:-
- Delete application on the website of Facebook (developers.facebook.com)
- Delete the file debug.keystore.
- Generate a new key (by running your app again)
- Create a new app on developers.facebook.com and add the new hash key
- Re-run your app
- Succes!
- 删除 Facebook 网站上的应用程序 (developers.facebook.com)
- 删除文件 debug.keystore。
- 生成新密钥(通过再次运行您的应用程序)
- 在 developer.facebook.com 上创建一个新应用并添加新的哈希键
- 重新运行你的应用
- 成功!
and more info see below link:-
以及更多信息,请参阅以下链接:-
https://developers.facebook.com/docs/android/getting-started/
https://developers.facebook.com/docs/android/getting-started/
回答by M.I.
Only one reason of this error which Hash key different for every development environment its mean that if you are working on different machines every PC/Mac will generate its own Hash Key.
这个错误的唯一原因是每个开发环境的哈希键都不同,这意味着如果您在不同的机器上工作,每台 PC/Mac 都会生成自己的哈希键。
NOW SOLUTION:
现在的解决方案:
IN two Simple step you can fix this error just write hash key in your Facebook Developer account like attached images:
在两个简单的步骤中,您可以修复此错误,只需在您的 Facebook 开发人员帐户中写入哈希键,如附加图像:
First Step: you will see here HASH KEY note hat key and then follow next step enter image description here
第一步:您将在此处看到 HASH KEY 注释帽子键,然后按照下一步 在此处输入图像描述
Last Step: write down copied hash key in Key Hashesfield. like enter image description here
最后一步:在Key Hashes字段中记下复制的哈希键。喜欢 在这里输入图片描述
No need to delete or reconfigure app.
无需删除或重新配置应用程序。
Thanks.
谢谢。
回答by Vasanth
回答by Karanveer Singh
In my case, I had changed the package name AFTER creating the private key, so, key hash was wrong/invalid.
就我而言,我在创建私钥后更改了包名称,因此,密钥哈希错误/无效。