3

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 , "App is misconfigured for Facebook login" error always happened in my device HTC One X.

keytool -exportcert -alias android -keystore C:\android2012\android.keystore | openssl sha1 -binary | openssl base64

I used the above-mentioned command to generate the Release key hash. The alias name is "android". It successfully generated the key hash after entering password. This key hash was input into the Facebook Dashboard and I tried to access in my signed APK but it failed.

Anyone can help? Stuck with this error for few days. Thanks a lot!

0

6 Answers 6

18

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.

7
  • @user1808006: Happy to have helped. :-) Nov 9, 2012 at 7:32
  • @NiravShah: I am glad it was useful. :-) May 2, 2013 at 10:16
  • That boolean doesn't exist in Util.java. Maybe it's changed recently?
    – MSpeed
    May 13, 2013 at 14:59
  • 1
    @billynomates: I believe it has since the 3.X Beta SDK. I haven't ventured into the new one yet. But with the mandatory update coming on the 21st of July, I should know conclusively soon enough. I am sure they have left something in there. I just have to hunt it down. Will update as soon as I can though. May 14, 2013 at 2:56
  • Solution 1 is Perfect !! Thak you very much! Jun 1, 2013 at 5:29
2

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"

0

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.

0

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...

0

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

0

to get openssl path follow this steps:

  1. download "openssl" for windows in zip
  2. extract zip in the path you want.
  3. get path for "bin" folder inside the zip

That's it

https://sourceforge.net/projects/openssl/files/latest/download

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.