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.08k stars 191 forks source link

Android build error in React Native 0.74 #491

Closed gabrielmaldi closed 2 months ago

gabrielmaldi commented 2 months ago
Task :react-native-safe-area-context:compileReleaseKotlin FAILED
e: file:///{project}/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
image
runNative commented 2 months ago

I solved it this way! WechatIMG51

private fun getInitialWindowMetrics(): Map<String, Any> { val decorView = reactApplicationContext.currentActivity?.window?.decorView as ViewGroup? val contentView = decorView?.findViewById(android.R.id.content) ?: return emptyMap() val insets = getSafeAreaInsets(decorView) val frame = getFrame(decorView, contentView) return mapOf( "insets" to (insets?.let { edgeInsetsToJavaMap(it) } ?: emptyMap()), "frame" to (frame?.let { rectToJavaMap(it) } ?: emptyMap()) ) }

chucongqing commented 2 months ago

they fixed it https://github.com/th3rdwave/react-native-safe-area-context/blob/996ec119ffd8e39cbbd542032066db2f5204ef42/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaContextModule.kt#L15-L17

FernandoAOborges commented 2 months ago

I did one patch. If anyone need. react-native-safe-area-context+4.9.0.patch

SumitSharmaJii commented 2 months ago

@FernandoAOborges @chucongqing @yuhao965472200 did you tried on new architecture?

mlazari commented 2 months ago

Updating to "react-native-safe-area-context": "4.10.0-rc.2" fixed this issue for me (newArchEnabled=false).

Riyad-Arafat commented 2 months ago

npm i react-native-safe-area-context@4.10.0-rc.2 I installed 4.10.0-rc.2 version and it worked fine

SumitSharmaJii commented 2 months ago

@FernandoAOborges @chucongqing @yuhao965472200 did you tried on new architecture?

"react-native-safe-area-context": "4.10.0-rc.2" works for new arch

jsp1024 commented 2 months ago

"react-native-safe-area-context": "4.10.0-rc.2" library works fine in RN ver.0.74.0

janicduplessis commented 2 months ago

I was waiting for the official release to make 4.10 the lastest version, will try to do that today.