Pushwoosh / pushwoosh-react-native-plugin

Other
57 stars 44 forks source link

[Bug]: Module exports two methods to JavaScript with the same name: "setUserId" #163

Closed kareem-adel closed 2 months ago

kareem-adel commented 4 months ago

Documentation

Description

When enabling new architecture in android I'm getting in logcat: Error: Exception in HostObject::get for prop 'Pushwoosh': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotations from native module: Pushwoosh. Details: Module exports two methods to JavaScript with the same name: "setUserId"

Bug severity

High

Steps to Reproduce

  1. Enable new architecture on android
  2. Build and run the app

Your Pushwoosh React Native Plugin version

6.1.30

Last worked Pushwoosh React Native Plugin version (if any)

No response

Affected platforms

Affected OS versions and/or devices

Pixel 3a API 34

Workaround

Commenting: //@ReactMethod //public void setUserId(String userId) { // PushwooshInApp.getInstance().setUserId(userId); //}

Relevant log output

Error: Exception in HostObject::get for prop 'Pushwoosh': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotations from native module: Pushwoosh. Details: Module exports two methods to JavaScript with the same name: "setUserId"

wfhm commented 4 months ago

@kareem-adel Hi, The plugin indeed has 2 setUserId methods exported, but this code is more than 4 years old and we have never received any similar reports so far. Also, I could not reproduce the issue on my side with the latest React Native version. Could you please specify what React Native version you are using in your project?

Grohden commented 3 months ago

Hey @wfhm maybe this is caused by the new arch (fabric I guess)... I don't use this package but I have a similar log for another one

E | ReactNativeJS ▶︎ Error: Exception in HostObject::get for prop 'UserLeapBindings': com.facebook.react.internal.turbomodule.core.TurboModuleInteropUtils$ParsingException: Unable to parse @ReactMethod annotations from native module: UserLeapBindings. Details: Module exports two methods to JavaScript with the same name: "configure

Seems somehow the TurboModuleInteropUtils parser doesn't understand what a method overload is anymore? 😞

I don't see anything suspicious here though

connorpmullins commented 3 months ago

I'm seeing a similar issue with the Iterable package. Have any of you found a fix?

Grohden commented 3 months ago

@connorpmullins I've looked at the history of that file and it seems that it was there since it was implemented... (by @rsnara in https://github.com/facebook/react-native/commit/1f7daf988b50005e3c659936c3e598aa3aa310f0) so I guess this is a breaking change... and a big one cuz any sane person in java would use method overloads 😞 (but I guess it makes sense for cross communication between js and java... or they just assume packages use kotlin)

My fix is a patch package (https://docs.sprig.com/discuss/667b2e307ac21e0018f77f68) for the specific reported package unifying the signatures and assuming the diff in the argument will be null.

However I've gave up in using the new arch since its not supported by the bottom sheet package we're using.

connorpmullins commented 3 months ago

Thanks @Grohden - I'll pass this over to the new arch discussion group and see if anyone else is encountering similar issues.

enginseer-dev commented 3 months ago

Hello @kareem-adel, @Grohden and @connorpmullins! We've fixed the issue with the newest release 6.1.32, please update the plugin in your apps and let us know if the issue persists.