7

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"/>
yonix
  • 11,665
  • 7
  • 34
  • 52

2 Answers2

3

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>
yonix
  • 11,665
  • 7
  • 34
  • 52
olegr
  • 1,999
  • 18
  • 23
  • 1
    Mmmm Facebook regular SDK integration guide says to add CustomTabActivity but not CustomTabMainActivity. The link you sent is interesting but if we don't support custom tabs in chrome and didn't change anything regarding this in the version how is this relevant? Didn't get if it can help me reproduce the problem and investigate... – yonix Mar 28 '18 at 11:34
  • OK eventually I found a crashing user and adding `com.facebook.CustomTabMainActivity` to the manifest like your link suggests indeed solved his crash. I wonder what was the root cause for this though as it didn't happen in previous versions of the app & the SDK. – yonix Mar 28 '18 at 19:59
  • @yonix i found this explaining how the workflow is. it is strange that nowhere in facebook it was documented like that https://gist.github.com/im182cm/808407b0b35613be4342c86de32a5882 – Emil Dec 01 '20 at 17:46
0

Have you declared FacebookActivity in manifest file like below.

<meta-data android:name="com.facebook.sdk.ApplicationId" 
        android:value="@string/facebook_app_id"/>

<activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />

Referrence

Sabyasachi
  • 3,499
  • 2
  • 14
  • 21