3

I got KeyHash using this. Of course, I copied this (KeyHash, package name and main activity class) to facebook settings according this.

And when I debug my app it looks fine (I can login and logout how many times I want), but when I create APK and run the app I received common error "invalid key hash the key hash does not match any stored key hash..."

What do I need to except getting right KeyHash and adding it into your Facebook App ID's Android settings?

Community
  • 1
  • 1
tauri
  • 293
  • 2
  • 6
  • 18
  • 2
    When you create an APK, typically you're using a different keystore than your debug keystore, so you're going to have a different key hash as well. You need to add that key hash to your developer settings as well. – Ming Li Apr 10 '15 at 22:47
  • Thank you! I didn't know that KeyHash is different. No I used command: "keytool -exportcert -alias -keystore "C:\Users\Beata\AndroidStudioProjects\\APK" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64". But still KeyHash is invalid. Did I use good this ? – tauri Apr 10 '15 at 23:36
  • The easiest way is to do it in code, and print it out in logcat. If you're using v4 of the SDK, you can just call FacebookSdk.getApplicationSignature(context) – Ming Li Apr 10 '15 at 23:46
  • How to call FacebookSdk.getApplicationSignature(context)? I receive null when I call it. – tauri Apr 11 '15 at 23:03
  • Can you post some code samples? If you're calling it from an activity, you should just call FacebookSdk.getApplicationSignature(this); – Ming Li Apr 13 '15 at 16:24
  • Thank you for your help. I solved the problem with keyhash for apk at last. – tauri Apr 15 '15 at 21:44

1 Answers1

8

You have to call

FacebookSdk.sdkInitialize(getApplicationContext());

before calling

FacebookSdk.getApplicationSignature(getApplicationContext());

to avoid getting NULL

This worked fine for me.

Vishnuvathsan
  • 615
  • 1
  • 9
  • 11
  • 1
    Please @Vishnuvathsan , I need you help on the project you help me with. Can you please send me the source code files you have on Fiverr? I hope you are feeling well! – MDDY Jun 27 '15 at 18:05