问题
I am building an app, which is going to have support for facebook. I have downloaded facebook API and their sample called "Hackbook" from original Git repos. The problem is with login - if original FB app is not installed on phone, the login is going through custom dialog and everything works, but if FB app is installed, the Hackbook automatically redirect to original FB app, and then nothing happened. It's impossible to login. I have tested this on five different phones, and always was the same problem.
回答1:
I had a similar problem. In my case, I had not created a hash key using my signing key. I just had the one hash key created using the debug.keystore default signing key.
As soon as i created a hash key using my app release signing key, that problem was sorted out. If you haven't already done this, create a new hash key using your signing key (for uploading on the market) and add that to your app's facebook control panel.
Hope this helps.
回答2:
I have toiled for two days & got the solution at last, this is the WRONG way to get the hash key -
keytool -exportcert -alias *<your _alias_name>* -keystore *<key_store_path>* | [openssl_bin_directory]\openssl sha1 -binary | [openssl_bin_directory]\openssl base64
The right way is type these 3 lines, one at a time in cmd. After the first line, you'll be asked to insert the keystore password.
keytool -exportcert -alias *<your _alias_name>* -keystore *<key_store_path>* > [openssl_bin_directory]\debug.txt
[openssl_bin_directory]\openssl sha1 -binary [openssl_bin_directory]\debug.txt > [openssl_bin_directory]\debug_sha.txt
[openssl_bin_directory]\openssl base64 -in [openssl_bin_directory]\debug_sha.txt > [openssl_bin_directory]\debug_base64.txt
If you want to know details, the RIGHT way is described here -
http://facebook.stackoverflow.com/questions/13281913/app-is-misconfigured-for-facebook-login-with-release-key-hash
or here
Facebook Android Generate Key Hash
回答3:
Get you hash key using this function for both(debug and release apk) and put it in your app in developer.facebook.com/apps
private void calculateHashKey(String yourPackageName) {
try {
PackageInfo info = getPackageManager().getPackageInfo(
yourPackageName,
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) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
this help me a lot.. Hope this will help you too..
回答4:
I have fixed this issue . After getting Key hash by using keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64 I have logged in first time in release mode successfully...
Then second time i got the common error
Your key "*********real*key************" does not match the allowed keys specified in your application settings.
Just use the "*********real*key************" which Facebook gives in error message I logged in successfully now in release mode.
So be sure while entering this key that you use the exact same key. The LETTERS I , small(L) i.e (l) will make you in trouble. I made two keys , in the first key I've used small(L) i.e (l) and in second key I've used I. and placed these keys in developer app.
It is working now ....
回答5:
In my case the problem was that the user-login gets cancelled when the facebook app is installed on the device even after generating right keys.
I added following line before login and it works great.
LoginManager.getInstance().logOut();
来源:https://stackoverflow.com/questions/10516401/facebook-api-login-fails-with-fb-app-installed-on-phone