segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
367 stars 191 forks source link

Build fail with new React Native (0.76) and latest @segment/analytics-react-native #1023

Closed edapess closed 1 week ago

edapess commented 3 weeks ago

Error:

> Task :segment_analytics-react-native:compileDebugKotlin FAILED
e: file:///Users/edmondavetisyan/Development/TPL/taild-mobile/node_modules/@segment/analytics-react-native/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt:128:30 Type mismatch: inferred type is String? but String was expected

Steps to reproduce Update project to new React Native and analytics-react-native to 2.20.2 Expected behavior Project should build successfully Actual behavior Build fails

Note

guys I already fixed it in this PR https://github.com/segmentio/analytics-react-native/pull/1022

elwafdy commented 3 weeks ago

Same issue here.

oferRounds commented 2 weeks ago

Update: sorry, missed the PR

anyone find a solution?

fkrein1 commented 1 week ago

@edapess Thanks! I’ve created a patch with your PR and it’s building now using patch-package.

@segment+analytics-react-native+2.20.2.patch


diff --git a/node_modules/@segment/analytics-react-native/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt b/node_modules/@segment/analytics-react-native/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt
index a6769bb..589ca78 100644
--- a/node_modules/@segment/analytics-react-native/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt
+++ b/node_modules/@segment/analytics-react-native/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt
@@ -125,7 +125,7 @@ class AnalyticsReactNativeModule : ReactContextBaseJavaModule, ActivityEventList
   @ReactMethod
   fun getContextInfo(config: ReadableMap, promise: Promise) {
     val appName: String = reactApplicationContext.applicationInfo.loadLabel(reactApplicationContext.packageManager).toString()
-    val appVersion: String = pInfo.versionName
+    val appVersion: String = pInfo.versionName.toString()
     val buildNumber = getBuildNumber()
     val bundleId = reactApplicationContext.packageName
alanjcharles commented 1 week ago

resolved in 2.20.3