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();
}
}