skip to Main Content

I have implemented login via facebook in android app and it is working fine when facebook app is installed on my device. after uninstalling the app, when hit login via facebook, it shows the facebook login screen, after granting permission for the app, it redirects me to the my login screen, but onActivityResult is not called, and I can’t click on any button in the screen. when I hit on back button, a transparent screen is closed, and onActicityResult is called with intent null.

In my gradle file I’m using the latest facebook version

implementation 'com.facebook.android:facebook-android-sdk:12.0.0

And this is the code I’m using in my activity:

 mCallbackManager = CallbackManager.Factory.create();
 
LoginManager.getInstance().registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                performFBLogin(loginResult);
            }

            @Override
            public void onCancel() {
                showErrorMessage(getResources().getString(R.string.facebook_login_canceled), true);
            }

            @Override
            public void onError(@NonNull FacebookException exception) {
                showErrorMessage(exception.getLocalizedMessage(), true);
            }
        });

And the click event is done like following:

        LoginManager.getInstance().logInWithReadPermissions(this, mCallbackManager, Arrays.asList("public_profile", "email"));

My manifest file looks like this:

  <activity
            android:name="com.facebook.CustomTabMainActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>


  <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" /> 
        <!-- [Facebook] -->
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>

Anyone face an issue like this?

Thanks

2

Answers


  1. I don’t know the reason of cause but I solved it by downgrading the appcomat version to 1.3.0 from 1.5.1 and inmobi mediation sdk version to 10.0.7.0 from 10.1.1.0.

        implementation 'androidx.appcompat:appcompat:1.3.0'
        implementation 'com.google.ads.mediation:inmobi:10.0.7.0'
    

    Application’s min sdk version is 19 and target sdk version is 30.

    Login or Signup to reply.
  2. This is a bug in Facebook’s SDK when working with AndroidX fragments / activity with version 1.5.0+

    https://github.com/facebook/facebook-android-sdk/blob/main/CHANGELOG.md#1411

    Just update your Facebook SDK to the latest version (recommended) OR downgrade your fragment / activity version (not recommended)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search