Android Why Facebook SDK Logout button not showing?
Asked Answered
I

2

6

I have developed an app with facebook login, there is no problem in the login process. But I do not see the button when I want to logout.

Broken App Screenshot

BROKEN APP

Working App Screenshot

WORKING APP

Broken app gradle files;

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    defaultConfig {
        applicationId "com.ex.ex"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // Glide image library
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'

    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

What is the source of the problem? How can i fix this?

Thanks.

Isonomy answered 24/2, 2017 at 8:42 Comment(5)
Probably useful if you post the Activity code & xml stuff. Probably a check that if you are logged in you don't show button.Twelvemo
The AlertDialog that opens after you click on the Facebook button comes with the Facebook SDK or is part of your app?Mutism
Did you find any solution, i am also facing the same issue. Please helpPorosity
try to change your sdk versionMendelian
I'm facing the same issue, were you able to solve it? I tried changing the sdk version but it didn't work!Abernathy
A
2

Try to Follow Facebook for Android Documentation

and use Latest Version compile 'com.android.support:appcompat-v7:25.2.0'

Follow this tutorial

compile 'com.google.android.gms:play-services:10.2.0'
Antifebrile answered 13/3, 2017 at 4:29 Comment(0)
E
0

I am assuming you have used LoginButton widget of Facebook android sdk.

When you click logout of LoginButton widget following code executes :

    protected void performLogout(Context context) {
        final LoginManager loginManager = getLoginManager();
        if (confirmLogout) {
            // Create a confirmation dialog
            String logout = getResources().getString(
                    R.string.com_facebook_loginview_log_out_action);
            String cancel = getResources().getString(
                    R.string.com_facebook_loginview_cancel_action);
            String message;
            Profile profile = Profile.getCurrentProfile();
            if (profile != null && profile.getName() != null) {
                message = String.format(
                        getResources().getString(
                                R.string.com_facebook_loginview_logged_in_as),
                        profile.getName());
            } else {
                message = getResources().getString(
                        R.string.com_facebook_loginview_logged_in_using_facebook);
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message)
                    .setCancelable(true)
                    .setPositiveButton(logout, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            loginManager.logOut();
                        }
                    })
                    .setNegativeButton(cancel, null);
            builder.create().show();
        } else {
            loginManager.logOut();
        }

}

confirmLogout flag is by default set to true unless specified false in widget xml file:

confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_com_facebook_confirm_logout, true);

So please check your xml file whether confirm_logout is set to false. But in that case, user will be logged out silently without displaying alert dialog.

Please post your jave code and xml code, if problem is still not resolved.

Ellie answered 11/3, 2017 at 9:35 Comment(1)
I checked the confirmLogout and it's set to true, but I still face the same issue as OP, do you have any idea what else I can do?Abernathy

© 2022 - 2024 — McMap. All rights reserved.