react-native-branch-deep-linking-attribution
react-native-branch-deep-linking-attribution copied to clipboard
`mActivity` is null in Android
Hey there -
We're running on version 5.0.1 and react-native version 0.63.X
About 10-15% of our Android user base is crashing due to mActivity being null on the following line.
https://github.com/BranchMetrics/react-native-branch-deep-linking-attribution/blob/a1c1d6e5bdcaa47faea2cd33e2c45fb951992634/android/src/main/java/io/branch/rnbranch/RNBranchModule.java#L232
Complete crash log is as follows
java.lang.RuntimeException:
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4907)
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4944)
at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2325)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8633)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.NullPointerException:
at io.branch.rnbranch.RNBranchModule.onNewIntent (RNBranchModule.java:232)
at com.ivynative.MainActivity.onNewIntent (MainActivity.java:31)
at android.app.Activity.performNewIntent (Activity.java:8222)
at android.app.Instrumentation.callActivityOnNewIntent (Instrumentation.java:1409)
at android.app.Instrumentation.callActivityOnNewIntent (Instrumentation.java:1422)
at android.app.ActivityThread.deliverNewIntents (ActivityThread.java:4074)
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4890)
As part of the integration, we followed the documentation. MainApplication.java looks like
@Override
public void onCreate() {
super.onCreate();
// some other initializations
// ...
RNBranchModule.getAutoInstance(this);
}
MainActivity.java looks like
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
RNBranchModule.onNewIntent(intent);
}
Per AndroidManifest.xml changes, we've added the followings to the appropriate places
<!-- goes under <activity for MainActivity -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="my-app.link" />
<data android:scheme="https" android:host="my-alternate.app.link" />
<data android:scheme="https" android:host="my-subdomain.hostname.com" />
</intent-filter>
<!-- goes under application -->
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_somerandomnumbersgoeshere" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="false" />
<!-- goes under application -->
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
It doesn't look like any changes made here in the 5.0.1+ releases. Any direction to help identify to root-cause or a possible fix is appreciated.
@eyaydin Did you find any hack for this?
Hi @eyaydin we would suggest to ensure the intent is not null before calling RNBranchModule.onNewIntent(intent); as you can see here: https://help.branch.io/developers-hub/docs/react-native#android-2