openwallet-foundation / askar

Secure storage designed for Hyperledger Aries agents.
Apache License 2.0
63 stars 51 forks source link

[react-native]: Duplicate symbols when building in Android #116

Closed genaris closed 1 year ago

genaris commented 1 year ago

After updating an app to use aries-askar-react-native@0.1.0-dev.4, I'm getting a build time error in Android regarding duplicate functions:

node_modules/@hyperledger/aries-askar-react-native/cpp/turboModuleUtility.cpp.o' -c ' /[project_dir]node_modules/@hyperledger/aries-askar-react-native/cpp/turboModuleUtility.cpp'
   /[project_dir]/node_modules/@hyperledger/aries-askar-react-native/cpp/turboModuleUtility.cpp:171:12: error: redefinition of 'createReturnValue'
  jsi::Value createReturnValue(jsi::Runtime &rt, ErrorCode code,
             ^
  /[project_dir]/node_modules/@hyperledger/aries-askar-react-native/cpp/turboModuleUtility.cpp:124:12: note: previous definition is here
  jsi::Value createReturnValue(jsi::Runtime &rt, ErrorCode code, int64_t *value) {
             ^
  1 error generated.

When building in an x86_64 PC, after removing one of these functions it also gave a similar error but with the template for int32_t.

Once that is removed, the app runs. However it could lead to issues when building for iOS (for that platform I have another problem, but that's another story :laughing: ).

TimoGlastra commented 1 year ago

Hmm, is there actually duplicate definitions here?

genaris commented 1 year ago

Hmm, is there actually duplicate definitions here?

Not literally, but it seems that for it int_64t * is equivalent to intptr_t * so it thinks it's a duplicate function prototype.

dviejokfs commented 1 year ago

@genaris

Could you let me know what you did to resolve it?

I was able to run it but got this runtime error: image

genaris commented 1 year ago

@genaris

Could you let me know what you did to resolve it?

I was able to run it but got this runtime error

I'm using it actually through aries-framework-javascript, so maybe there is something different in the way the module is initialized between my setup and yours. I haven't seen an error like that during this (long) journey though.

Just for info I attach the patch I did to make it build in Android. Curiously it works in iOS as well with those functions commented.

@hyperledger+aries-askar-react-native+0.1.0-dev.4.patch

TimoGlastra commented 1 year ago

This is fixed