Android Facebook SDK: Key hash does not match any

2020-02-07 16:26发布

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

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$3.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$2.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?

8条回答
欢心
2楼-- · 2020-02-07 17:02

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

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.

More information: Facebook docs

查看更多
forever°为你锁心
3楼-- · 2020-02-07 17:02

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..


查看更多
时光不老,我们不散
4楼-- · 2020-02-07 17:05

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

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

查看更多
三岁会撩人
5楼-- · 2020-02-07 17:07

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=.

查看更多
劫难
6楼-- · 2020-02-07 17:07

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.

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

查看更多
老娘就宠你
7楼-- · 2020-02-07 17:10

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.zip on windows, you cannot use openssl-0.9.8k_X64.zip

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

Reference

查看更多
登录 后发表回答