-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Error on setup: "Method addObserver must be called on the main thread" #255
Comments
@cristeahub Hi there! I am currently facing the same issue with another RN library. |
There's a chain of issues here, but #256 fixed the issue for me. You can read more on this issue: segmentio/analytics-android#725 and I used this patch here at one point to fix it: segmentio/analytics-android#725 (comment) . |
The patch says we should call However
In the library that is causing the issue for me ( I am very inexperienced with Java/Kotlin, sorry if this does not make much sense. |
You'll have to take that up with the library authors. I'm not familiar with that library. |
I have migrated to another library since Thank you for your help anyways! |
Hi All! just wanted to call out that we have shipped the change to fix the main issue in |
Hi,
After upgrading one of my other dependencies in my android app (namely Stripe Android SDK from 10.x to 16.x) I surprisingly encountered an error in this SDK. Note that one of the changes from this huge jump is that the StripeSDK has migrated to AndroidX.
When i do
analytics.setup(MY_WRITE_KEY, {some: 'options'}
I get a redbox in my app with the textwriteKey must not be null or empty
.I have debugged and verified that the writeKey is indeed set correctly, so this is just a symptom and not the actual issue.
Digging further down I found that when initializing the Segment Android SDK I got the following error
Method addObserver must be called on the main thread
. This seems to be the actual issue causing my subsequent calls toanalytics
to fail due to the writeKey not being set.The error is caught here:
analytics-react-native/packages/core/android/src/main/java/com/segment/analytics/reactnative/core/RNAnalyticsModule.kt
Lines 187 to 191 in 226a9e4
This error comes from the
analytics-android
package that this package depends on. The error seems to stem from AndroidX issues, and there's even an issue on that repo for the error: segmentio/analytics-android#725 .This is a blocker for us now, I am asking here since we are using react native and there was no answer from the developers at the other repo. Is there a way to escalate this issue so it gets attention and gets fixed?
I found a related issue from a different vendor here: getsentry/sentry-android#520 . This issue was about lifetime handlers, which both the original issue creator on the segment-android repo and myself use. However simply turning that off was not enough to fix the issue.
Alternatively do you know of any workarounds?
Thanks for a great library otherwise!
The text was updated successfully, but these errors were encountered: