Skip to content

fix(android): crash on New Architecture in trackDeepLinks#1146

Open
RomanSytnyk wants to merge 1 commit intosegmentio:masterfrom
RomanSytnyk:fix/new-architecture-track-deep-links
Open

fix(android): crash on New Architecture in trackDeepLinks#1146
RomanSytnyk wants to merge 1 commit intosegmentio:masterfrom
RomanSytnyk:fix/new-architecture-track-deep-links

Conversation

@RomanSytnyk
Copy link

@RomanSytnyk RomanSytnyk commented Mar 4, 2026

Summary

Crash on Expo 55

trackDeepLinks() in AnalyticsReactNativeModule.kt accesses SovranModule through the old ReactNativeHost chain:

val sovran = (reactApplicationContext.currentActivity?.application as ReactApplication)
  ?.reactNativeHost
  ?.reactInstanceManager
  ?.currentReactContext
  ?.getNativeModule(SovranModule::class.java)

This throws a RuntimeException on React Native's New Architecture (Bridgeless mode):

java.lang.RuntimeException: You should not use ReactNativeHost directly in the New Architecture

The crash happens on every app launch (onHostResume) and on deep links (onNewIntent).

Fix

Use reactApplicationContext.getNativeModule() directly

trackDeepLinks() accessed SovranModule through the old ReactNativeHost
chain (ReactApplication -> reactNativeHost -> reactInstanceManager ->
currentReactContext -> getNativeModule), which throws a RuntimeException
on React Native's New Architecture (Bridgeless mode):

  "You should not use ReactNativeHost directly in the New Architecture"

The fix uses reactApplicationContext.getNativeModule() directly, which
is the same pattern already used by setAnonymousId() in this class.

Also removes unused ReactApplication and ReactActivity imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant