amplitude / Amplitude-TypeScript

TypeScript Amplitude Analytics SDK
https://amplitude.github.io/Amplitude-TypeScript/
MIT License
132 stars 38 forks source link

Fails to build on RN 0.76 #901

Open johnf opened 1 week ago

johnf commented 1 week ago

Expected Behavior

Package should build succesfully

Current Behavior

Task :amplitude_analytics-react-native:compileDebugKotlin FAILED e: file:///home/johnf/work/gladly/mobile/node_modules/@amplitude/analytics-react-native/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt:64:25 Type mismatch: inferred type is String? but String was expected

Possible Solution

diff --git a/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt b/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt
index cfe7bcab8600fcfdf5d8dd77aeb4ba68ac0a8100..93f2101121cf7e69878f7faeb09ba0e298b9812e 100644
--- a/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt
+++ b/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt
@@ -55,7 +55,7 @@ class LegacyDatabaseStorage(context: Context, databaseName: String) : SQLiteOpen

     private fun queryDb(
         db: SQLiteDatabase,
-        table: String?,
+        table: String,
         columns: Array<String?>?,
         selection: String?,
         selectionArgs: Array<String?>?,

Steps to Reproduce

Standard steps to add @amplitude/analytics-react-native to your project

Environment

Other

As a side note is this package built from this repo? I tried to do a PR but the file in question doesn't exist

MonikaGupta756 commented 1 week ago

I am facing the same issue only in Android but with RN 0.73.6

node_modules/@amplitude/analytics-react-native/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt:64:25 Type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.
huextrat commented 1 week ago

This is on Kotlin SDK, here is a proposal to fix it: https://github.com/amplitude/Amplitude-Kotlin/pull/228

izaaz commented 1 week ago

The RN SDK does not use the kotlin SDK underneath. This is the file that needs to be changed

https://github.com/amplitude/Amplitude-TypeScript/blob/v1.x/packages/analytics-react-native/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt

But I wonder why its failing now though? Its been like this for a long time. Do y'all use a stricter type checking that makes this fail?

huextrat commented 6 days ago

The RN SDK does not use the kotlin SDK underneath. This is the file that needs to be changed

https://github.com/amplitude/Amplitude-TypeScript/blob/v1.x/packages/analytics-react-native/android/src/main/java/com/amplitude/reactnative/LegacyDatabaseStorage.kt

But I wonder why its failing now though? Its been like this for a long time. Do y'all use a stricter type checking that makes this fail?

@izaaz Ah, good point, we'll have to patch this version with the fix then.

This issue has only existed since version 0.76 of RN, probably due to a change in compatibility with Kotlin

dpyeates commented 11 hours ago

any update on this change getting added please?

younes0 commented 10 hours ago

It seems surprising that Amplitude isn't being very responsive about their React Native SDK (this issue, new architecture...)

This appears particularly noteworthy given React Native's growing popularity among major apps and companies. One has to wonder if Amplitude's Product Managers are aware of this situation. https://reactnative.dev/showcase