Search code examples
androidfacebookfacebook-android-sdkfacebook-sdk-3.0

Android facebook login not working with installed Facebook app


I have set up simple facebook login. For Android 2.3.6 everything works as should, user gets prompt login dialog, enters data and app goes on. I thought that it was android versions fault but it turs out that the login isn't working when there is facebook application installed on the phone!

Tested this on: Galaxy Ace 2.3.6 HTC Desire 4.1.2 Galaxy Note 4.1.2 Android emulator 4.1.2

Even the facebook samples are not working!

Every time the app is executing - else { Log.d("SESSION NOT OPENED", "SESSION NOT OPENED"); }

It seems like session isn't opened but why is that? Followed this guide - https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/

Code:

Session.openActiveSession(this, true, new Session.StatusCallback() {

        @Override
        public void call(final Session session, SessionState state, Exception exception) {

            if (session.isOpened()) {

                Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        if (user != null) {
                            Log.d("Access_token", session.getAccessToken());
                        }
                    }
                });
            } else {
                Log.d("SESSION NOT OPENED", "SESSION NOT OPENED");
            }
        }
    });

Solution

  • Check out the bottom of step 4: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/

    If you have not entered your app key hash properly, Facebook login via the WebView popup (if the app is not installed) will still work, but login via the native Facebook app won't.

    You should see this exception in LogCat:

    com.facebook.http.protocol.ApiException: remote_app_id does not match stored id
    

    The Facebook SDK prints its exceptions so check there anyway if there are other problems.