expo: [Android] [expo-analytics-segment] ExponentSegment: Method addObserver must be called on the main thread
Summary
Hello,
When I try to initialize Segment, I receive this error :
[Unhandled promise rejection: Error: Encountered an exception while calling native method: Exception occurred while executing exported method initialize on module ExponentSegment: Method addObserver must be called on the main thread]
This has been tested with Expo Go on Android device.
Cheers 😄
Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
41.0.1
Environment
Expo CLI 4.5.2 environment info: System: OS: macOS 11.2.3 Shell: 5.8 - /bin/zsh Binaries: Node: 14.16.1 - /var/folders/k6/cqlnsz8x0756r83kbyb0s2700000gp/T/fnm-shell-5389680/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.12 - /var/folders/k6/cqlnsz8x0756r83kbyb0s2700000gp/T/fnm-shell-5389680/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /Users/colisweb/.rvm/gems/jruby-9.2.13.0/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 12.4/12D4e - /usr/bin/xcodebuild npmPackages: expo: ~41.0.1 => 41.0.1 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 react-native-web: ~0.13.12 => 0.13.18 npmGlobalPackages: expo-cli: 4.5.2 Expo Workflow: managed
Reproducible demo or steps to reproduce from a blank project
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 12
- Comments: 33 (10 by maintainers)
Hi! Any chances to get this working on Expo 41? I believe that it has been fixed here https://github.com/expo/expo/pull/13263
Any updates on this? Observing the same issue on android, no Segment events are being registered as a result
The beta was just updated so you should be able to install the new Expo Go client (
expo client:install:android) - I just tested and verified its working nowIn the future we’ll be documenting updates to the beta during testing, so you’ll have better visibility on when changes are available for use!
@snowshiva I was having the same issue a couple of days ago and I fixed my bug today. I was somehow calling Segment.identify() before Segment.initialize(). I fixed my flow and now every Segment.track() call contains the userId as expected. I hope this helps.
@ajsmth I spoke too soon - while data is flowing into segment now, all calls from android are failing because my destination in segment requires userId for
trackWithProperties, and for some reason that is automatically being passed for my iOS source but not my Android source. I’m testing now if I can manually includeuserIdto fix in the short run but seems like something is still wrong there.@ajsmth is the next beta release going to be mentioned on the Expo blog?
iOS events working fine in Segment, android doesn’t work at all.
expo diagnosticsThis should be available in Expo 42 - the beta is out now! https://blog.expo.io/expo-sdk-42-beta-is-now-available-e505770389e7