facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 906 forks source link

[Android] react-native-fbsdk 1.1.2 / 2.0.0 , RN 0.61.5 NullPointerException at com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused #750

Closed erisvaldojunior closed 4 years ago

erisvaldojunior commented 4 years ago

Having a lot of crashes with production users (RN 0.61.5, react-native-fbsdk). Integration seems to work fine and no crashes on iOS, only Android. Wasn't able to replicate it locally but Google Play Console shows tons of it.

PS: integration was made following github README instructions, no manual changes to gradle or MainApplication.java, just yarn add react-native-fbsdk , AndroidManifest.xml, strings.xml as suggested. Any ideas?

Huawei P20 Pro (HWCLT), Android 9
Report 1 of 1
java.lang.RuntimeException: 
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4742)
  at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4691)
  at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:4626)
  at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2199)
  at android.os.Handler.dispatchMessage (Handler.java:112)
  at android.os.Looper.loop (Looper.java:216)
  at android.app.ActivityThread.main (ActivityThread.java:7625)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)

Caused by: java.lang.NullPointerException: 
  at com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused (CodelessActivityLifecycleTracker.java:129)
  at android.app.Application.dispatchActivityPaused (Application.java:260)
  at android.app.Activity.onPause (Activity.java:1839)
  at androidx.fragment.app.FragmentActivity.onPause (FragmentActivity.java:470)
  at com.facebook.react.ReactActivity.onPause (ReactActivity.java:57)
  at android.app.Activity.performPause (Activity.java:7663)
  at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1536)
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4726)

Originally posted by @cihati in https://github.com/facebook/react-native/issues/24498#issuecomment-524234973

erisvaldojunior commented 4 years ago

Seems related to https://github.com/facebook/react-native-fbsdk/pull/699 , probably it should be fixed on 1.1.2 but it is still happening.

janicduplessis commented 4 years ago

Can you try 2.0.0, it updates facebook sdk to v7.0.

erisvaldojunior commented 4 years ago

@janicduplessis thanks for the reply. We've upgraded to 2.0.0, I could check that iOS pods are now using FBSDKCore/Share/Login 7.0, but we are still seeing crashs for production users on Android (hundreds per day). Same stack trace, happens on several devices on Android 9.0 Pie.

The react-native-fbsdk is used only for attribution / deferred app links. We also use AppEventsLogger which seems to work fine on both platforms.

More info about the Android config:

package.json "react": "16.9.0", "react-native": "0.61.5", "react-native-fbsdk": "^2.0.0",

MainApplication.java (no change, guess shouldn't add FBSDKPackage to getPackages() because of autolink)

build.gradle, settings.gradle (no change, guess shouldn't add include/project/implementation 'react-native-project-fbsdk' because of autolink

strings.xml (facebook_app_id properly set)

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

erisvaldojunior commented 4 years ago

@janicduplessis any clue?

Hamawis commented 4 years ago

@erisvaldojunior were you able to resolve it?

erisvaldojunior commented 4 years ago

@Hamawis not yet, unfortunately.

NweThazin commented 4 years ago

@erisvaldojunior Hi, are you able to solve that issue?

Hamawis commented 4 years ago

I fixed this by upgrading fbsdk version to 2.0.0. So no more crashes reported.

adamfellon commented 4 years ago

We're still seeing these issues in production on fbsdk 2.0.0, RN v0.61.5. @Hamawis can you share what version of react-native you are using as well?

Anyone else have v2.0.0 fix their issue? If so, do you mind sharing the RN version you're currently using? Think our next steps are going to be trying to update to 0.63.2

adamfellon commented 4 years ago

Found our issue. We had previously been on a RN version < 0.60.0, so we had manually applied the facebook dependencies in our build.gradle to point to have implementation 'com.facebook.android:facebook-android-sdk:4.34.0' ...just had to remove that and re-build & submit and that was the fix.

janicduplessis commented 4 years ago

Will close as I think this is not related to this library and the crash comes from an old version of the facebook android sdk. If you are seeing this issue make sure you don't specify com.facebook.android:facebook-android-sdk:x in your build.gradle and use version 2.0+ of this library.

imwexpex commented 4 years ago

Will close as I think this is not related to this library and the crash comes from an old version of the facebook android sdk. If you are seeing this issue make sure you don't specify com.facebook.android:facebook-android-sdk:x in your build.gradle and use version 2.0+ of this library.

Hi! Looks like this method not works, because we still receive a lot of expections.

imwexpex commented 4 years ago

com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused

java.lang.RuntimeException: 
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4742)
  at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4691)
  at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:4626)
  at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:45)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:145)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2199)
  at android.os.Handler.dispatchMessage (Handler.java:112)
  at android.os.Looper.loop (Looper.java:216)
  at android.app.ActivityThread.main (ActivityThread.java:7625)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)
Caused by: java.lang.NullPointerException: 
  at com.facebook.marketing.CodelessActivityLifecycleTracker$1.onActivityPaused (CodelessActivityLifecycleTracker.java:129)
  at android.app.Application.dispatchActivityPaused (Application.java:260)
  at android.app.Activity.onPause (Activity.java:1839)
  at androidx.fragment.app.FragmentActivity.onPause (FragmentActivity.java:417)
  at com.facebook.react.ReactActivity.onPause (ReactActivity.java:50)
  at android.app.Activity.performPause (Activity.java:7663)
  at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1536)
  at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4726)