react-native-safe-area-context icon indicating copy to clipboard operation
react-native-safe-area-context copied to clipboard

Build failed: Kotlin complaining type mismatch in SafeAreaContextModule.kt

Open objectkuan opened this issue 1 year ago • 6 comments

build.gradle of my app

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 23
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "26.1.10909125"
        kotlinVersion = "1.9.22"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
        classpath("com.google.gms:google-services:4.4.0")
    }
}

The error:

e: file:///.../react-native-safe-area-context/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextModule.kt:17:63 Type mismatch: inferred type is Map<String, Any>? but Any was expected

The screenshot:

image

objectkuan avatar Jul 11 '24 13:07 objectkuan

React Native version & version of this library?

jacobp100 avatar Jul 11 '24 13:07 jacobp100

React Native version & version of this library?

[email protected] [email protected]

objectkuan avatar Jul 11 '24 14:07 objectkuan

Just found a workaround by changing

return MapBuilder.of<String, Any>("initialWindowMetrics", getInitialWindowMetrics())
return MapBuilder.of<String, Any>("initialWindowMetrics", getInitialWindowMetrics()!!)

Looks like the Map doesn't allow null values?

objectkuan avatar Jul 11 '24 14:07 objectkuan

Maybe try updating react-native-safe-area-context?

jacobp100 avatar Jul 11 '24 14:07 jacobp100

I am also having this issue with same verisions. Can we get a fix for this in the package?


> Task :react-native-safe-area-context:compileReleaseKotlin FAILED
e: file:///Users/Exposure/Development/AppDevRN/node_modules/react-native-safe-area-context/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextModule.kt:17:63 Type mismatch: inferred type is Map<String, Any>? but Any was expected

cblaze22 avatar Jul 15 '24 16:07 cblaze22

MapBuilder.of

@objectkuan Where is this change is supposed to be made, which file? Thank you.

vlad-ps avatar Aug 15 '24 16:08 vlad-ps