Android KeyHash Valid when Debug, Invalid when I i

2019-05-12 09:03发布

问题:

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?

回答1:

You have to call

FacebookSdk.sdkInitialize(getApplicationContext());

before calling

FacebookSdk.getApplicationSignature(getApplicationContext());

to avoid getting NULL

This worked fine for me.