I\'ve intergrated Facebook to my App. I tested my App with Debug Key Hash was alright in emulator and my device HTC. When I tried the Release Key Hash for my signed APK , \"
to get openssl path follow this steps:
That's it
https://sourceforge.net/projects/openssl/files/latest/download
I have had this Problem for two months now. My key hashes have been pyling up to 9. Today i finally found the simple solution:
STEP 1:
Install the facebook sdk you downloaded from the facebook developer page on your phone. Don´t install the normal facebook app. Make sure you can log into facebook. Then log out.
STEP 2:
Export your app with your final release key as an apk, like you would when uploading it to the playstore.
STEP 3:
Put the Apk file on your phone via usb cable or usb stick.
STEP 4:
Install your app, using a file manager: For example https://play.google.com/store/apps/details?id=com.rhmsoft.fm
STEP 5:
Launch your app and try to log in with facebook. A dialog will open and tell you: "the key has not been found in the facebook developer console
STEP 6:
Write down the key.
STEP 7:
Put it into your facebook developer console and save. Now you are done. Anyone that downloads your app, published with earlier used keystore can log into facebook.
Enjoy
This issue occur may be because of we are using "openssl-0.9.8k" versions. Try to use different version either "openssl-0.9.8e" or "openssl-0.9.8d" from the below link :
https://code.google.com/p/openssl-for-windows/downloads/list
This issue will not arise.
Why it works on the emulator or even on the device while you are testing it is because, while testing from eclipse, you use the debug.keystore and not your release key.
Follow one of the two solutions below, and you should be good to go.
Solution 1:
Try this link: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1. I found that using the Facebook method of getting a Hash Key did not always work as advertised. This link however, has a different method of getting the Hash Key and has pretty much always worked.
Solution 2:
That being said, I always found the simplest thing to do was, let the Facebook SDK tell you what your Hash Key is. This is by far more simpler and shouldn't take more than a couple of minutes.
Step 1: In your Facebook SDK, locate the Util.java class. In that, change this:
private static boolean ENABLE_LOG = false;
to:
private static boolean ENABLE_LOG = true;
Step 2: Create a new Signed APK, transfer to your device and install. If it is already installed, naturally, it will prompt.
Step 3: With your DDMS (Logcat) running and your device connected to the computer, run the application and keep looking for a key mismatch warning. That warning has the actual Hash Key. Copy that key, go to your Facebook Developer page and add the new key to the list.
Siddharth's solution 2 sometimes isn't possible in Facebook SDK 3.0 onwards. Use the following code to toast the right key hash inside your app itself.
try {
PackageInfo info = getPackageManager().getPackageInfo("com.package.mypackage", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT);
Log.e("MY KEY HASH:", sign);
Toast.makeText(getApplicationContext(),sign, Toast.LENGTH_LONG).show();
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
replace com.package.mypackage with your package name...
I was stuck on this issue for about a week! I wanted to generate hash key for my own keystore and not the debug.keystore. I've tried every possible solution on the web...
Finally I've came to a strange understanding:
keytool -exportcert -alias androiddebugkey -keystore [PATH_TO_KEYSTORE]\debug.keystore | [PATH_TO_OPENSSL]\openssl sha1 -binary | [PATH_TO_OPENSSL]\openssl base64
using this method I was asked for the password and received a hash key (wrong one)
second method in three steps proposed here Facebook Android Generate Key Hash
keytool -exportcert -alias androiddebugkey -keystore [PATH_TO_KEYSTORE]\debug.keystore > [PATH_TO_OPENSSL]\debug.txt [PATH_TO_OPENSSL]\openssl sha1 -binary [PATH_TO_OPENSSL]\debug.txt > [PATH_TO_OPENSSL]\bin\debug_sha.txt [PATH_TO_OPENSSL]\openssl base64 -in [PATH_TO_OPENSSL]\bin\debug_sha.txt > [PATH_TO_OPENSSL]\bin\debug_base64.txt
using this method I was also asked for the password and received a different hash key = the correct one...
P.S. Put your alias instead of "androiddebugkey" and your keystore instead of "debug.keystore"