th3rdwave / react-native-safe-area-context

A flexible way to handle safe area insets in JS. Also works on Android and Web!
MIT License
2.11k stars 193 forks source link

Build failed: Kotlin complaining type mismatch in SafeAreaContextModule.kt #511

Open objectkuan opened 1 month ago

objectkuan commented 1 month ago

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

jacobp100 commented 1 month ago

React Native version & version of this library?

objectkuan commented 1 month ago

React Native version & version of this library?

react-native@0.74.3 react-native-safe-area-context@4.8.2

objectkuan commented 1 month ago

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?

jacobp100 commented 1 month ago

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

cblaze22 commented 1 month ago

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
vlad-ps commented 6 days ago
MapBuilder.of

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