My app uses a simple facebook login. I have entered the keyhash in my app dashboard, key_hash section and I was able to login successfully. Now I have published the app and
For me, when I ran the keytool command and it prompted me for a password, I interpreted this to mean I need to choose a password for the hash. In fact, you need to provide they password to the keystore (the location where the hash is kept). Funny thing is (not funny, "ha ha"), it will accept any password and output a hash for you. That caused my hash to not match. Luckily I had stored my password in OS X keychain long ago, so I found what it really is. I tried the correct password and got a different hash which worked. Note that the default keystore password is android, so try that, it might be what you're missing.
I really think an incorrect password ought to reject you rather than outputting a hash, I wonder if this is a bug – if so, please leave a bug report link in the comments.
Using Debug key store including android's debug.keystore present in .android folder was generating a strange problem; the log-in using facebook login button on android app would happen perfectly as desired for the first time. But when ever I Logged out and tried logging in, it would throw up an error saying: This app has no android key hashes configured. Please go to http:// ....
Creating a Keystore using keytool command(keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 10000) and putting this keystore in my projects topmost parent folder and making a following entry in projects build.gradle file solved the issue:
signingConfigs {
release {
storeFile file("my-release-key.keystore")
storePassword "passpass"
keyAlias "alias_name"
keyPassword "passpass"
} }
Please note that you always use the following method inside onCreate() of your android activity to get the key hash value(to register in developer.facebook.com site of your app) instead of using command line(keytool -exportcert -alias -keystore | openssl sha1 -binary | openssl base64) to generate hash value as command line in some cased may out put a wrong key hash:
public void showHashKey(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo("com.superreceptionist",
PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT);
Log.e("KeyHash:", sign);
// Toast.makeText(getApplicationContext(),sign, Toast.LENGTH_LONG).show();
}
Log.d("KeyHash:", "****------------***");
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
Try to generate new key hash and edit it in facebook developers and register app with new key hash again.