Android Facebook SDK:上传 google play 时,密钥哈希与任何存储的密钥哈希都不匹配

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20506658/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:57:09  来源:igfitidea点击:

Android Facebook SDK: Key hash does not match any stored key hashes when uploading google play

androidfacebook-loginandroid-facebook

提问by leojg

My app uses facebook api for user login. On developing it works fine, but when I uploaded it to google play it stops working.

我的应用程序使用 facebook api 进行用户登录。在开发它工作正常,但是当我将它上传到谷歌播放时它停止工作。

This is the error log:

这是错误日志:

12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284): Exception during service
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284): com.facebook.http.protocol.ApiException: Key hash XXXXXXX does not match any stored key hashes.
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.ApiResponseChecker.b(ApiResponseChecker.java:83)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.ApiResponseChecker.a(ApiResponseChecker.java:162)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.ApiResponse.g(ApiResponse.java:239)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:272)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.katana.server.protocol.AuthorizeAppMethod.a(AuthorizeAppMethod.java:29)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.ApiResponseHandler.a(ApiResponseHandler.java:56)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.ApiResponseHandler.handleResponse(ApiResponseHandler.java:29)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:280)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:141)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:103)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:196)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:374)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:151)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:18)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.katana.server.handler.PlatformOperationHandler.c(PlatformOperationHandler.java:367)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.katana.server.handler.PlatformOperationHandler.a(PlatformOperationHandler.java:260)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:299)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:53)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.fbservice.service.BlueServiceQueue.run(BlueServiceQueue.java:230)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:59)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at android.os.Handler.handleCallback(Handler.java:733)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at android.os.Handler.dispatchMessage(Handler.java:95)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at android.os.Looper.loop(Looper.java:137)
12-10 20:20:02.488: W/fb4a(:<default>):BlueServiceQueue(17284):     at android.os.HandlerThread.run(HandlerThread.java:61)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284): Failed to send
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284): com.facebook.fbservice.service.ServiceException: API_ERROR: API_ERROR
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:640)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at com.facebook.fbservice.ops.BlueServiceOperation.c(BlueServiceOperation.java:48)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at com.facebook.fbservice.ops.BlueServiceOperation.run(BlueServiceOperation.java:605)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at android.os.Handler.handleCallback(Handler.java:733)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at android.os.Handler.dispatchMessage(Handler.java:95)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at android.os.Looper.loop(Looper.java:137)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at android.app.ActivityThread.main(ActivityThread.java:4998)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at java.lang.reflect.Method.invokeNative(Native Method)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at java.lang.reflect.Method.invoke(Method.java:515)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-10 20:20:02.498: W/fb4a(:<default>):GDPDialog(17284):    at dalvik.system.NativeStart.main(Native Method)

Could it be that the key hash changed in some way?

会不会是密钥散列以某种方式改变了?

回答by Milk Man

I spent a full day trying to figure out why this wasn't working...

我花了一整天试图弄清楚为什么这不起作用......

When generating the hash key for production you need to use openssl-0.9.8e_X64.zipon windows, you cannot use openssl-0.9.8k_X64.zip

在为生产生成哈希键时,您需要在 windows上使用openssl-0.9.8e_X64.zip,不能使用openssl-0.9.8k_X64.zip

The versions produce different hash keys, for some reason 9.8k does not work correctly... 9.8e does

版本产生不同的哈希键,出于某种原因 9.8k 不能正常工作...... 9.8e 可以

Reference

参考

回答by Ramon Vicente

You followed the steps that facebook provides for the creation of a login application?

您是否按照 facebook 提供的步骤创建登录应用程序?

You need a 'Production keyhash' obtained starting your release keystore:

您需要在开始发布密钥库时获得“生产密钥哈希”:

From comand line:

从命令行:

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

And add this key on facebook app page options.

并在 facebook 应用程序页面选项上添加此密钥。

More information: Facebook docs

更多信息:Facebook 文档

回答by patrickfdsouza

This was giving the wrong key for me.

这给了我错误的钥匙。

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

A workaround that worked for me was: 1. Put this code in your launching activity

对我有用的解决方法是: 1. 将此代码放在您的启动活动中

private void printKeyHash(){
    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "YOUR_PACKAGE_NAME", 
                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) {
        Log.d("KeyHash:", e.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.d("KeyHash:", e.toString());
    }
}
  1. Export the app for publishing on play store using the .keyStore
  2. Install the app before uploading to play store and run it and note the keyHash printed.
  3. Add the keyHash to the Facebook App.
  1. 使用 .keyStore 导出应用程序以在 Play 商店中发布
  2. 在上传到 Play 商店之前安装应用程序并运行它并注意打印的 keyHash。
  3. 将 keyHash 添加到 Facebook 应用程序。

Hope this helps someone.

希望这可以帮助某人。

回答by Micky

You can also just take the missing hash from the stack trace of the ApiException: Key hash XXXXXXX does not match any stored key hashes. There you have it already, only missing the =at the end. So take XXXXXXX=.

您也可以从 ApiException: 的堆栈跟踪中获取丢失的哈希值Key hash XXXXXXX does not match any stored key hashes。你已经有了它,只是=在最后错过了。所以取 XXXXXXX=。

回答by Satheesh

This is working fine to me

这对我来说很好用

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

Where <RELEASE_KEY_ALIAS>is your Alias name while you create signed application.

<RELEASE_KEY_ALIAS>创建签名应用程序时,您的别名在哪里 。

enter image description here

在此处输入图片说明

And <RELEASE_KEY_PATH>is Location in the below picture And then enter the password is key create passwordin the below picture instead of android

<RELEASE_KEY_PATH>是下图中的位置然后输入密码是密钥在下图中创建密码而不是android

enter image description here

在此处输入图片说明

回答by Prayag

Above solutions are correct to a point. But if someone still faces an issue . Delete the key from developer profile and add it again writing= at the end and press enter . You have to add key in both settings and developer.

以上解决方案在一定程度上是正确的。但如果有人仍然面临问题。从开发人员配置文件中删除密钥并在末尾再次添加 write= 并按 enter 。您必须在设置和开发人员中添加密钥。

I was facing issues with app release to google play and using release key

我在向 google play 发布应用程序和使用发布密钥时遇到了问题

回答by vinay shetty

I solved the issue in the simple way..

我以简单的方式解决了这个问题..

1)Frist Logout from the FaceBook app.

2)Open the Appplication which you have developed when cilck to login it will show the haskkey not mathcing.

3)Generate the SHA1 signing report in (Right Side Tab android studio) Gradle-->Task-->android->signing Report .(HEXA String)

4)Convert that to base 64.(Link) 5)Copy the output and past in the FaceBook developer page..

1)首先从FaceBook应用程序注销。

2)点击登录时打开您开发的应用程序,它会显示haskkey not mathcing。

3)在(Right Side Tab android studio)Gradle-->Task-->android->signing Report .(HEXA String)中生成SHA1签名报告

4) 将其转换为 base 64。(链接) 5) 在 FaceBook 开发人员页面中复制输出和过去..



回答by kshitij

please check point no. 9 on Enable Single Sign On for Your App

请检查点号。9 on为您的应用启用单点登录

Enable Single Sign On Enable single sign on for your app by setting Single Sign On to Yes below. YesNo Single Sign On

启用单点登录 通过将下面的单点登录设置为是,为您的应用启用单点登录。是否单点登录