Take the 2-minute tour ×

I have tried


And I get a keyhash 1knQ67Fx4PUOYXggSe+mnzqaTL8=.

But google's own documentation suggests an alternative too.

try {
    PackageInfo info = getPackageManager().getPackageInfo(
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {

But this yields UR02fNgzyMOjpWCxUnjGZ4ctF6Y=. I have doubly verified that and I get these two values consistently with the respective approaches.

Why are they different? And which one should I register at developers.facebook.com? The documentation is not very clear it seems.


As Offbeatmammal says I can register multiple keys at facebook site. So that's ok. But I should also specify the keyhash in application manifest file. So additionally asking: which one should I use there in the application? I can of course try it but an answer would be welcome as well.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You will essentially need at least 2 Key Hashes for your application. This is assuming, you are working on just one computer. For additional computer, you will need to generate and add one more Key Hash to your App's settings in the Developer Console.


While you are testing your application, eclipse (in conjunction with the ADT / SDK) will always use the debug.keystore for pushing the app to the device or the emulator. When you publish the app, you use the keystore that you generate for your app (for publishing to Google Play).

Facebook requires the Key Hashes for both the debug.keystore as well as your own keystore.

To address your concern that you get different Key Hashes using 2 different methods, is something I have faced when I started using the Facebook Android SDK. To circumvent that, I found a solution that always works and is always precise. You can follow the steps in these answers (they are almost the same) and you will have your Key Hash working in no time:

  1. http://stackoverflow.com/a/13283088/450534
  2. http://stackoverflow.com/a/13343529/450534
  3. http://stackoverflow.com/a/10516629/450534 (The solution is in the comments in this one)

So, to sum it up:

  1. Try using the steps from the links provided above to let the Facebook SDK tell you the correct Key Hash.
  2. And as for which Key Hash is to be used: You won't have to decide that. Since you will have added both the Key Hashes to your Developer Console, Facebook will use the appropriate one automatically.
  3. I am not aware of needing to add the Key Hash to the Manifest file. It perhaps may be a requirement of the Facebook SDK v3. In such a case, while testing, use the Key Hash created with the debug.keystore and when you are ready to release the App, change to the Key Hash created using your release keystore.

Hope this addresses your question.


As Offbeatmammal as already pointed out, you can add multiple Key Hashes to your Developer Console. So storing and using multiple Key Hashes is something you won't have to worry about.

share|improve this answer
Do you know why the two approaches are giving different results? –  nawfal Jan 18 '13 at 7:17
@nawfal: I am not entirely sure why this happens. I had the same problem when I started with the SDK. I realized it was best to use the one that the SDK itself generates for you. Takes the worrying out of it. I have however heard people say that JRE7 may be the culprit. But this cannot be verified. –  Siddharth Lele Jan 18 '13 at 7:25
Yes I have heard the same too.. –  nawfal Jan 18 '13 at 7:26
sorry for the late acceptance. I was wrong to say I have to add a key hash to mainfest file. Actually what I have to add to mainfest file is an "id" facebook developers site generates. I provided both the keyhashes/keystores to facebook to which facebook returned one, which i added in my manifest file. I need not worry if they gave me correct or not, because facebook itself gave me! :) cheers.. –  nawfal Mar 21 '13 at 10:28
add comment

I've always used the keytool signature. the good thing is that the Facebook form where you register signatures supports multiple ones (which is handy if you either hand multiple apps, or need to support multiple appstores and end up with different hashes)

share|improve this answer
That's fine, but I also have to use the keyhash in the application. So there I really have to use the right one I suppose.. –  nawfal Jan 18 '13 at 0:41
add comment

Your Answer


