-
-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Problem Description
When building the Android app with React Native 0.81.5 and Expo SDK 54, I encountered a Kotlin compilation error in BlurhashViewManager.kt:
Return type mismatch: expected 'MutableMap<String, Any>?', actual 'Map<String, Any>'.
The issue occurs in the getExportedCustomDirectEventTypeConstants() method. The method signature requires a return type of MutableMap<String, Any>?, but MapBuilder.builder().build() returns an immutable Map<String, Any>, which causes a type mismatch.
Solution
The fix is simple: convert the immutable Map to a MutableMap by calling .toMutableMap() on the result of .build().
Environment
- react-native-blurhash: 2.1.2
- React Native: 0.81.5
- Expo SDK: 54.0.20
- Kotlin: 2.1.20
- Android Gradle Plugin: Compatible with Expo SDK 54
Here is the diff that solved my problem (showing only the relevant change):
diff --git a/node_modules/react-native-blurhash/android/src/main/java/com/mrousavy/blurhash/BlurhashViewManager.kt b/node_modules/react-native-blurhash/android/src/main/java/com/mrousavy/blurhash/BlurhashViewManager.kt
index 9224e9a..7e0fc81 100644
--- a/node_modules/react-native-blurhash/android/src/main/java/com/mrousavy/blurhash/BlurhashViewManager.kt
+++ b/node_modules/react-native-blurhash/android/src/main/java/com/mrousavy/blurhash/BlurhashViewManager.kt
@@ -114,6 +114,7 @@ class BlurhashViewManager :
.put(LoadStartEvent.EVENT_NAME, MapBuilder.of("registrationName", "onLoadStart"))
.put(LoadEndEvent.EVENT_NAME, MapBuilder.of("registrationName", "onLoadEnd"))
.build()
+ .toMutableMap()
}
override fun getName() = REACT_CLASSThis ensures that the return type matches the method signature MutableMap<String, Any>?, resolving the compilation error.
This issue body was partially generated by patch-package.