This was giving the wrong key for me.
keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
A workaround that worked for me was:
1. Put this code in your launching activity
private void printKeyHash(){
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"YOUR_PACKAGE_NAME",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
Log.d("KeyHash:", e.toString());
} catch (NoSuchAlgorithmException e) {
Log.d("KeyHash:", e.toString());
}
}
- Export the app for publishing on play store using the .keyStore
- Install the app before uploading to play store and run it and note the keyHash printed.
- Add the keyHash to the Facebook App.
Hope this helps someone.