So I’ve implemented Facebook Login in my Android app for a while now, and it’s been working fine for months.
The problems began when I updated the SDK version to one of the latest (4.22.0). After this point, clicking the Facebook Login button just causes a brief attempt at logging in and then nothing. From the log I can see onCancel() in the FacebookCallback is being called but that’s it.
Everything works fine when I uninstall the Facebook app. I go through the web view login and then I’m able to proceed (onSuccess() is called).
I’ve tried reverting back to the SDK version I was using earlier, but no luck. I’ve checked that my KeyHashes match (both debug and release) what’s on the Facebook Developer Dashboard, and it does. My App ID matches too.’
I know that I’m logged out prior to attempting a login since I’m forcing a logout with LoginManager.
It’s very odd. I used the following code to generate my KeyHash:
try {
PackageInfo info = getPackageManager().getPackageInfo(
"***.*****.************",
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 (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
3
Answers
Try to using that code for fackbook hash key generation.
I used following steps to generate a Key Hash for my app in facebook:
Navigate in the terminal to the directory where your Android debug.keystore is stored. Mostly in Windows it will located under “/Users/user_name/.android/” and in Windows will be C:Documents and Settings.android).
In mac – Type cd ~/.android and hit enter to go to .android directory
Once you are in the “.android” directory, run the following command to get a debug key..
keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
Use the same procedure to get the Release key. Just replace the command with the following and use your release key alias.
keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | “PATH FOR openssl.exe” sha1 -binary | openssl base64
When it prompts you for a password, type android and hit Enter
Copy the value printed in the terminal that ends with an “=” and paste it in the Key Hash field in Facebook. Then click the Save Changes button.