-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The app crashes on Android with New Architecture (Bridgeless mode) enabled. The crash occurs on every cold launch via onHostResume
and on deep links via onNewIntent.
Environment
- @segment/analytics-react-native: 2.22.0
- React Native: New Architecture enabled (newArchEnabled=true)
- Expo SDK: 55
Stack trace
java.lang.RuntimeException: You should not use ReactNativeHost directly in the New Architecture
com.facebook.react.ReactApplication.getReactNativeHost(ReactApplication.kt:20)
com.segmentanalyticsreactnative.AnalyticsReactNativeModule.trackDeepLinks(AnalyticsReactNativeModule.kt:221)
com.segmentanalyticsreactnative.AnalyticsReactNativeModule.onHostResume(AnalyticsReactNativeModule.kt:255)
com.facebook.react.bridge.ReactContext.onHostResume(ReactContext.java:255)
com.facebook.react.runtime.ReactLifecycleStateManager.moveToOnHostPause(ReactLifecycleStateManager.kt:50)
com.facebook.react.runtime.ReactHostImpl.onHostPause(ReactHostImpl.kt:284)
com.facebook.react.ReactDelegate.onHostPause(ReactDelegate.kt:156)
com.facebook.react.ReactActivityDelegate.onPause(ReactActivityDelegate.java:196)
expo.modules.ReactActivityDelegateWrapper$onPause$1.invokeSuspend(ReactActivityDelegateWrapper.kt:201)
In React Native's New Architecture, ReactApplication.getReactNativeHost() throws a RuntimeException
Suggested fix
Use reactApplicationContext.getNativeModule() directly: the same pattern already used by setAnonymousId() in the same file:
val sovran = reactApplicationContext.getNativeModule(SovranModule::class.java)
See PR: #1146
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working