Android KeyHash Valid when Debug, Invalid when I install the App from APK
Asked Answered
C

1

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?

Connoisseur answered 10/4, 2015 at 21:52 Comment(6)
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.Ben
Thank you! I didn't know that KeyHash is different. No I used command: "keytool -exportcert -alias <name_of_jks_file> -keystore "C:\Users\Beata\AndroidStudioProjects\<app_name>\APK" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64". But still KeyHash is invalid. Did I use good this <name_of_jks_file> ?Connoisseur
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)Ben
How to call FacebookSdk.getApplicationSignature(context)? I receive null when I call it.Connoisseur
Can you post some code samples? If you're calling it from an activity, you should just call FacebookSdk.getApplicationSignature(this);Ben
Thank you for your help. I solved the problem with keyhash for apk at last.Connoisseur
G
9

You have to call

FacebookSdk.sdkInitialize(getApplicationContext());

before calling

FacebookSdk.getApplicationSignature(getApplicationContext());

to avoid getting NULL

This worked fine for me.

Gnat answered 2/6, 2015 at 7:49 Comment(1)
Please @Gnat , 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!Trinatrinal

© 2022 - 2024 — McMap. All rights reserved.