Skip to content
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

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

Open
objectkuan opened this issue Jul 11, 2024 · 6 comments

Comments

@objectkuan
Copy link

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
Copy link
Collaborator

React Native version & version of this library?

@objectkuan
Copy link
Author

React Native version & version of this library?

[email protected]
[email protected]

@objectkuan
Copy link
Author

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
Copy link
Collaborator

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

@cblaze22
Copy link

cblaze22 commented Jul 15, 2024

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
Copy link

vlad-ps commented Aug 15, 2024

MapBuilder.of

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants