0

I'm working on facebook android sdk. I'm getting the hash key using following code .Now I'm getting error Session state CLOSED_LOGIN_FAILED after login to Facebook.

Ref : if(session.isOpen()), facebook login on android always returning false

try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "your.root.package", 
                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) {

    } catch (NoSuchAlgorithmException e) {

    }
Community
  • 1
  • 1
Kirit Vaghela
  • 12,572
  • 4
  • 76
  • 80
  • 1
    The only way the Key Hash will change is when the signing key changes. And this never happens on it's own. If you are still developing and deploying via USB using the default `debug.keystore` and you delete it and re-create a new one is the only scenario I can think of. And, unfortunately, in the eventuality that the Key Hash has changed, the new Key Hash has to be **manually updated** in your Facebook Developer console. There is no such feature (_and for a good reason too_) that allows your app (regardless of the platform) to edit / modify details in your FB Dev console. – Siddharth Lele Jul 31 '13 at 11:04
  • My actual problem is getting session state equals to false every time http://stackoverflow.com/questions/16176832/ifsession-isopen-facebook-login-on-android-always-returning-false – Kirit Vaghela Jul 31 '13 at 11:08
  • If you are facing the same problem as the one in that question, the code you have used will fix it. Having said that, my earlier comment still remains valid. _but my app is not work when hash key on facebook is automatically changed_: As mentioned earlier, it **does not** change on it's own. _hash key is change on Facebook or any other way to set hash key programmatically from android app_: It **cannot** be done. You will have to update the new Hash Key manually in your Facebook Developer console. – Siddharth Lele Jul 31 '13 at 11:16
  • Ok.I will try suggestion of deleting debug.keystore – Kirit Vaghela Jul 31 '13 at 11:23
  • NO NO! I am **not suggesting / asking** you to delete anything!! I was listing a possibility of when the Key Hash will change!! Again, **do not delete anything**. – Siddharth Lele Jul 31 '13 at 11:24
  • dont worry it will recreated when I run my app again. I try this step but still same result – Kirit Vaghela Jul 31 '13 at 11:27
  • No I am not worried. It's just that doing so is not a solution and neither was I suggesting it was. In fact, I am not even sure what the real issue is. Perhaps a little details added to the OP would help. – Siddharth Lele Jul 31 '13 at 11:29
  • I can not find the exact problem.can you suggest me what can I do. – Kirit Vaghela Jul 31 '13 at 11:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34529/discussion-between-kirit-and-siddharth-lele) – Kirit Vaghela Jul 31 '13 at 11:39
  • getting error after login `Session state CLOSED_LOGIN_FAILED` – Kirit Vaghela Jul 31 '13 at 11:41
  • Have you ever solved this issue? I am having same problem, and i have already checked my hashkey... – yahya Mar 24 '14 at 14:03

1 Answers1

-1

OK MY SONS! LISTEN TO THIS SOLUTION AND BE SAVED

go to this solution and folow carefully: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1

now pay close attention: you must do it with java 1.6!!

in my case i did it twice like he suggested on my original keystore file as well-not sure if this is essential.

last but not least: go to the android developer site and press Status and Reviews make your app public and open champein!

(i really hate face)

Gal Rom
  • 6,221
  • 3
  • 41
  • 33