Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Facebook SDK (4.31.0) - ActivityNotFoundException in CustomTabLoginMethodHandler

Since we deployed a new version of our Android app with updated Facebook SDK, we see many users are crashing on Facebook Login. It doesn't reproduce on our devices.

Crash and stacktrace:

Caused by android.content.ActivityNotFoundException
Unable to find explicit activity class {<our_app_id>/com.facebook.e}; have you declared this activity in your AndroidManifest.xml?

    android.app.Instrumentation.checkStartActivityResult (Instrumentation.java:1850)
    android.support.v4.app.Fragment.startActivityForResult (Fragment.java:916)
    com.facebook.login.CustomTabLoginMethodHandler.tryAuthorize (CustomTabLoginMethodHandler.java:102)
    com.facebook.login.LoginClient.tryCurrentHandler (LoginClient.java:255)
    com.facebook.login.LoginClient.tryNextHandler (LoginClient.java:217)
    com.facebook.login.LoginClient.authorize (LoginClient.java:122)
    com.facebook.login.LoginClient.startOrContinueAuth (LoginClient.java:103)
    com.facebook.login.LoginFragment.onResume (LoginFragment.java:154)
    android.support.v4.app.Fragment.performResume (Fragment.java:2308)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832)

Any ideas what could be causing the crash and how to fix?

=== EDIT ===

Notice that only some of the users are crashing, and when tested locally it seems that we can login without problems.

We defined the Facebook activities in the manifest like recommended in the official documentation:

<activity
    android:name="com.facebook.FacebookActivity"
    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"/>
like image 478
yonix Avatar asked Mar 28 '18 08:03

yonix


People also ask

How do I update my Facebook SDK?

Select the App you want to upgrade (you might have access to multiple apps) Click Settings > Advanced. Select the latest version under the Upgrade API Version section for both “Upgrade All Calls” and “Upgrade Calls for App Roles” Save.


1 Answers

From stacktrace and Facebook SDK sources it seems that com.facebook.e is an obfuscated name for com.facebook.CustomTabMainActivity. I don't know under which circumstances Facebook SDK calls this Activity but if it is called then it should be defined in AndroidManifest.xml.

Since it is not defined in your manifest, it will not be obfuscated.

According to this link the missing part of your manifest is:

<activity
    android:name="com.facebook.CustomTabMainActivity"
    android:exported="true">
</activity>
like image 60
olegr Avatar answered Oct 29 '22 16:10

olegr