software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.86k stars 1.29k forks source link

V2: Upgrade error `InnerNativeModule.installCoreFunctions` #846

Closed xignor closed 2 years ago

xignor commented 4 years ago

Description

When running the app after 1.8 to 2 upgrade Reanimated throws this error:

Error: Requiring module "node_modules/react-native-reanimated/src/reanimated2/index.js", which threw an exception: TypeError: null is not an object (evaluating 'InnerNativeModule.installCoreFunctions')

Screenshots

image

Steps To Reproduce

  1. Upgrade from1.8.0 to 2.0.0-alpha.1
  2. Update babel.config.js, AppDelegate.h, AppDelegate.mm to reflect changes in https://docs.swmansion.com/react-native-reanimated/docs/installation

Package versions

roots-ai commented 2 years ago

For wanderers having this issue on iOS (or very similar, something about the JSI module not having the VM reference early on).. Make sure to init RCTRootView using the appropriate initializer with the help of RCTBridgeDelegate

RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
                                          launchOptions:launchOptions];

RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                 moduleName:@"MyApp"
                                          initialProperties:initialProps];

Not initWithBundleURL

This gives this error Use of undeclared identifier 'initialProps'

roots-ai commented 1 year ago

Tried with

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
                                             launchOptions:launchOptions];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                    moduleName:@"MyApp"
                                             initialProperties:nil];

But now this gives another error and the app doesn't build


*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate sourceURLForBridge:]: unrecognized selector sent to instance 0x283b010e0'

Any updates here?

ybonnetain commented 1 year ago

Tried with

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
                                             launchOptions:launchOptions];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                    moduleName:@"MyApp"
                                             initialProperties:nil];

But now this gives another error and the app doesn't build


*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate sourceURLForBridge:]: unrecognized selector sent to instance 0x283b010e0'

Any updates here?

You need to conform to RCTBridgeDelegate in order to use these bridge and view initializers. See the following gist for a complete example. https://gist.github.com/ybonnetain/7b3e510050447ae52c0f8d6dd741d9d4

roots-ai commented 1 year ago

@ybonnetain it's giving a compilation error Use of undeclared identifier '$'

Here is my AppDelegate.m

Stuck on this issue error since months now.

ybonnetain commented 1 year ago

Line 71, sorry it's @ not $.

But you also need to conform to RCTBridgeDelegate.

You may want to move this issue to stackoverflow and DM me the link ;)

roots-ai commented 1 year ago

https://stackoverflow.com/questions/73917181/typeerror-undefined-is-not-an-object-installcorefunctions-react-native-reanim

roots-ai commented 1 year ago

@ybonnetain Facing issues. InstallCoreFunction seems to crash with another error . com.facebook.react.JavaScript (9): EXC_BAD_ACCESS (code=1, address=0xffffa0000c250698

rougeEloma commented 1 year ago

was facing same problem "react-native": "0.66.0", "react-native-reanimated": "^2.3.0-beta.2",

I changed in android/app/build.gradle project.ext.react = [ enableHermes: true ]

and in the MainApplication.java I added on top import com.facebook.react.bridge.JSIModulePackage; import com.swmansion.reanimated.ReanimatedJSIModulePackage; and in the function ReactNative Host () I added @Override protected JSIModulePackage getJSIModulePackage() { return new ReanimatedJSIModulePackage(); }

It worked like a charm

hi. i can't find android/app/build.gradle on my pc.

Aggroid commented 1 year ago
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
                                          launchOptions:launchOptions];

RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                 moduleName:@"MyApp"
                                          initialProperties:initialProps];

I don't know if you fix it but with the new react-native there is no more initialProperties:initialProps so instead of that use this solution but change initialPropertis:nil .

RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];

RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"appName" initialProperties:nil];

That's how I made it work on react-native 0.68.1