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

React Native 0.76 - Error: Exception in HostObject::get for prop 'GooglePayButtonConstants' #38

Open
ganoro opened this issue Feb 4, 2025 · 1 comment

Comments

@ganoro
Copy link

ganoro commented Feb 4, 2025

Describe the bug
When I use the plugin with RN 0.76 with the new architecture I see this error while compiling the code:

Error: Exception in HostObject::get for prop 'GooglePayButtonConstants': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotation from native module method: GooglePayButtonConstants.getConstants(). Details: Unable to parse JNI signature. Detected unsupported return class: java.util.HashMap

To Reproduce
Steps to reproduce the behavior:

  1. Create a new RN 0.76 project
  2. Add the library
  3. Add the GooglePay button
  4. When you compile - See error
    Error: Exception in HostObject::get for prop 'GooglePayButtonConstants': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotation from native module method: GooglePayButtonConstants.getConstants(). Details: Unable to parse JNI signature. Detected unsupported return class: java.util.HashMap

Expected behavior
The project should be compiled correctly

Screenshots
Error: Exception in HostObject::get for prop 'GooglePayButtonConstants': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotation from native module method: GooglePayButtonConstants.getConstants(). Details: Unable to parse JNI signature. Detected unsupported return class: java.util.HashMap

Desktop (please complete the following information):

Smartphone (please complete the following information):

  • Android Google Phone

Additional context

@ganoro
Copy link
Author

ganoro commented Feb 4, 2025

Here is the diff that solved my problem:

diff --git a/node_modules/@google/react-native-make-payment/android/src/main/java/com/makepayment/GooglePayButtonConstantsModule.kt b/node_modules/@google/react-native-make-payment/android/src/main/java/com/makepayment/GooglePayButtonConstantsModule.kt
index aeca448..0240fe7 100644
--- a/node_modules/@google/react-native-make-payment/android/src/main/java/com/makepayment/GooglePayButtonConstantsModule.kt
+++ b/node_modules/@google/react-native-make-payment/android/src/main/java/com/makepayment/GooglePayButtonConstantsModule.kt
@@ -3,16 +3,19 @@ package com.makepayment
 import com.facebook.react.bridge.ReactApplicationContext
 import com.facebook.react.bridge.ReactContextBaseJavaModule
 import com.google.android.gms.wallet.button.ButtonConstants
+import com.facebook.react.bridge.Arguments
+import com.facebook.react.bridge.WritableMap
+import com.facebook.react.bridge.WritableNativeMap
 
 class GooglePayButtonConstantsModule(reactContext: ReactApplicationContext) :
     ReactContextBaseJavaModule(reactContext) {
 
-    override fun getConstants(): HashMap<String, Any> {
-        val themes = hashMapOf<String, Int>()
+    override fun getConstants(): MutableMap<String, Any> {
+        val themes = mutableMapOf<String, Int>()
         themes["Dark"] = ButtonConstants.ButtonTheme.DARK
         themes["Light"] = ButtonConstants.ButtonTheme.LIGHT
 
-        val types = hashMapOf<String, Int>()
+        val types = mutableMapOf<String, Int>()
         types["Book"] = ButtonConstants.ButtonType.BOOK
         types["Buy"] = ButtonConstants.ButtonType.BUY
         types["Checkout"] = ButtonConstants.ButtonType.CHECKOUT
@@ -22,7 +25,10 @@ class GooglePayButtonConstantsModule(reactContext: ReactApplicationContext) :
         types["Plain"] = ButtonConstants.ButtonType.PLAIN
         types["Subscribe"] = ButtonConstants.ButtonType.SUBSCRIBE
 
-        return hashMapOf("Themes" to themes, "Types" to types)
+        return mutableMapOf(
+            "Themes" to themes,
+            "Types" to types
+        )
     }
 
     override fun getName() = NAME

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

1 participant