9

I am trying Android Facebook integration for an app. I am new to this.

I have got the Facebook SDK & I am trying to run a few samples from there. When I run the samples I get this error " (# 404) Keyhash XXXXXX does not match any stored key hashes ".

The XXXXXX is probably my keyhash, I did some basic search about what it is. I read this and I compared the XXXXXX value with the Java Keytool.exe from my machine. There was a match with these numbers.

I have to get this working - I feel I have to add this somewhere on Facebook developer site. Can someone tell me if thats correct & also how to do it. OR my approach may be wrong too, if you can guide me to the correct approach. That will be helpful.

Thanks!

1
  • You have to add this hashkey in the facebook developer console of your app. Mar 7, 2014 at 7:36

4 Answers 4

14

After spending few hours and referring few answers here. finally its worked for me. few observations:

  1. hashcode generated by Keytool is not same as hashcode showing in exception. Use the later one.
  2. For Facebook Sample apps we need to add the hash for SampleApp.Here if we entered the hash and click on SaveChanges its clearing and not saved.So before clicking the SaveChanges need to hit the enter key and make sure its not clearing.
  3. need to append = at the end of hashkey shown in exception.
3
  • #1 may be wrong. The keytool one works for me. My problem was I was in a hurry, so I had not filled in package name
    – Karthik T
    May 8, 2014 at 9:30
  • 1
    Ug! Adding the = after the hash in the error was the key.
    – Jay
    May 25, 2014 at 21:55
  • 1
    You can get the hashcode shown in the exception by adding a snippet of code as described here: developers.facebook.com/docs/android/getting-started/… Nov 18, 2014 at 18:27
11

Assuming that you know how to create a hash key, I suggest you to follow the below steps to add a hash key in FaceBook developer console of your app,

1. After creating a app, click on settings from the left side panel.

2. Select add platform.

3. From the pop up, select Android as your platform.

4. There you will find fields to enter Package Name, Class Name, and hash Keys.

5. Fill up the respective fields.You can enter many hash keys as well.

Note : If you enter wrong hash key, then it will show you the same error again.

hope it helps.

1

While generating release Hash key, Note this

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

OR

Use this below flow

This is how I solved this problem Download your APK to your PC in java jdk\bin folder in my case C:\Program Files\Java\jdk1.7.0_121\bin go to java jdk\bin folder and run cmd then copy the following command in your cmd

keytool -list -printcert -jarfile yourapkname.apk

Copy the SHA1 value to your clip board like this CD:A1:EA:A3:5C:5C:68:FB:FA:0A:6B:E5:5A:72:64:DD:26:8D:44:84 and open Hex To Base 64 to convert your SHA1 value to base64.

For MAC

Step 1:

Generate SHA1 key by using below command
keytool -list -v -keystore
Enter Keystore password.
Copy SHA1 Key.

Step 2:
Open this link - Hex To Base 64
Paste the SHA1 Key in Hex String
Click convert button
Get the Release Keyhash in Output value

0

In addition to being aware of hash issues, you also need to make sure that the Facebook account on the device is an admin account, develop account or an account that has permission to participate in the test.

1
  • 2
    It appears you have written the same answer in 2 different languages - SO is a english-only site. Could you remove any other languages?
    – Tyler2P
    Apr 2, 2021 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.