4

I'm authenticating user's (or trying to) with my android app that I've been working on and all I get from the facebook dialog is that an error has occurred with no details as to what the error is. There are not exceptions being thrown for me to chase or anything of the sort. I've followed http://developers.facebook.com/docs/guides/mobile/#android to create my login dialog.

The page says use new Facebook("YOUR_APP_ID"); which results in the error, I've also tried the api key but it gives the same thing. I'm not doing anything else except toasting but I don't even get a response in the callback until I hit the return key to leave the facebook dialog

public class Base {
private Facebook fb;

    public Base() {
        fb = new Facebook("app_id_here");
    }

    public void onCreate(Bundle b) {
        super.onCreate(b);
    }

    private void doLogin() {
        fb.authorize(this, new DialogListener() {
            public void onComplete(Bundle values) {
                Toast.makeText(getApplicationContext(), values.toString(),
                        Toast.LENGTH_LONG).show();
            }
            public void onFacebookError(FacebookError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(),
                        Toast.LENGTH_LONG).show();

            }

            public void onError(DialogError e) {
                Toast.makeText(getApplicationContext(), e.getMessage(),
                        Toast.LENGTH_LONG).show();
            }

            public void onCancel() {
                Toast.makeText(getApplicationContext(),
                        "You must be registered and signed in to perform that action",
                        Toast.LENGTH_LONG).show();

            }
        });
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        fb.authorizeCallback(requestCode, resultCode, data);
    }
}

Any idea why this will be giving an error or where/how I can find what's causing the error P.S I've also added the key hash under "Mobile and Devices" on the FB app settings page and this isn't the same problem as found over at Login failed invalid key error with Facebook SDK I've tried the suggestions over there. It doesn't work

2 Answers 2

15

I also faced this problem. First of all I need to know which Key Hash value you entered on facebook app if it is 'ga0RGNYHvNM5d0SLGQfpQWAPGJ8=' then that is the problem. I think you entered

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

this one on the terminal and you entered your own password to generate the key hash. if you done that please try do the following things also you enter the above command on terminal(I am using UBUNTU(linux). You type the command corresponding to which OS you are using) and enter the password as 'android'. This time you will get a different hey hash value. Copy that value and save it as the key hash value for your facebook app. After that check it is working or not. For me it worked. This will occur when we are using the debug key. After all this when you are about to publish this application on the Android market you will have to again change the key hash value according to the private key you are using. Try this may be this will help you.

4
  • That's exactly the case...is there a link documenting this anywhere? Thanks it now works, not sure I follow you about when I'm ready to publish the App...which private key?
    – zcourts
    May 26, 2011 at 14:33
  • Sorry just realise you meant the signing stage developer.android.com/guide/publishing/app-signing.html
    – zcourts
    May 26, 2011 at 14:44
  • So happy to know that it worked for you. I don't understand what you actually meant by this "not sure I follow you about when I'm ready to publish the App...which private key?". when you are about to publish the app, we have to sign the code right. After signing the code we will get key. From that key which you got after signing the code, you have to generate a separate key hash value for the facebook otherwise this same problem will arise again.
    – Basil
    May 27, 2011 at 4:53
  • I get identical keys with "android" or "" as the password. Both are the same ones I've been using successfully for ages.
    – Timmmm
    Nov 1, 2012 at 17:31
0

In my case, "~/.android/debug.keystore" was the "KEY" of this problem. Check the "debug.keystore"'s folder URL. You must change this to right URL exactly. And then, Run the command below..

$ cd /cygdrive/c/Users/watchout/.android <==== My Debug Keystore URL $ keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary| openssl base 64

It asked "password", but the debug keystore doesn't have the password. So, You can just press "enter key" and it toss me a key. I used it then I solved this problem. Try again, robinsonc494!

2
  • I thought the default password was 'android'
    – Blundell
    Aug 3, 2011 at 21:35
  • The password you enter doesn't actually make any difference, but facebook do tell you to use "android".
    – Timmmm
    Nov 14, 2012 at 19:48

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.