react-native-reanimated: The native part of Reanimated doesn't seem to be initialized
Description
After upgrading to react-native 0.72.1
and react-native-animated 3.3.0
im no longer able to start the app in dev, with metro server throwing the following error:
Error: [Reanimated] The native part of Reanimated doesn't seem to be initialized. This could be caused by
- not rebuilding the app after installing or upgrading Reanimated
- trying to run Reanimated on an unsupported platform
- running in a brownfield app without manually initializing the native library
I’ve spent half a day on this error and come up with nothing, im stumped.
The error im seeing is on IOS, im not very familiar with the IOS native files so im not really sure where to look here. This was working on version 2.14.4
.
Have been through all the recommended steps
- Triple checked bable.config.js
- Cleared caches, rebuilt pods
- Even wiped node_modules, cleared cached and rebuilt again.
- Tried latest nightly
3.4.0
build - Rolling back a version to 3.2.0
Same issues… What am I missing here?
index.js
import "react-native-gesture-handler";
import { AppRegistry } from "react-native";
import App from "./App";
AppRegistry.registerComponent('main', () => App);
babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ["module:metro-react-native-babel-preset"],
plugins: [
"@babel/plugin-proposal-unicode-property-regex",
"react-native-reanimated/plugin",
],
};
};
Let me know if you need to see other files
Steps to reproduce
- Start dev server
react-native start --reset-cache
- Build app
yarn ios
- App boots, starts loading bundle, crashes with error
Snack or a link to a repository
Sorry I dont have one…
Reanimated version
3.3.0
React Native version
0.72.1
Platforms
iOS
JavaScript runtime
None
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
iOS simulator
Device model
iPhone 14
Acknowledgements
Yes
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 14
- Comments: 29 (2 by maintainers)
I managed to fix it by running:
npx react-native-clean-project
And clearing all IOS files and Pods.
@nikolal
Wow, many many thanks, I didn’t know this package but it works very very well. My app is now building
my stack :
This is fixed with the combo of RN 0.72.x and RNR 3.4.x So no need to modify any app delegate files.
And don’t forget to do
pod install
and also to start metro with --reset-cache to pick up the new version of the babel pluginGo too your babel config. js file and add These to you code plugins : [ ‘react-native-reaanimated/plugins’] and go back too you Terminal and restart with these command line npm start – —reset–cache
SUCCESS!
It is most certainly Nx related. My knowledge of dependency loading is not the deepest so this is a bit of a guess, but Nx doesn’t seem pick up on peer dependencies of implicit dependencies (the ones it establishes by analyzing source code). The reason this was a problem was that Nx’s
sync-deps
step didn’t update the target’s package.json with thereact-native-reanimated: "*"
entry that would signal Nx React Native to scan the package and install the corresponding Pods if necessary. So I didn’t have a Reanimated Pod at all.So if you use Nx and run into this, add
to the package.json of your target. Then run the
npx nx pod-install [target]
, and you should be good to go!After installing the library, I ran
expo run:ios
and this fixed the error for me.I’m also still seeing this issue. Have spent several hours troubleshooting and still getting this error. I’m using NX monorepo:
Have run react-native-project-clean. Have manually cleaned. Have restarted computer. Have deleted node_modules and cleared npm cache. Have deleted pods and reinstalled. Have cleared watchman and metro cache. I’ve gone into xcworkspace and manually cleaned and rebuilt. I’ve reset all content and settings from my iOS simulator. This project is brand new, just generated using nx-create-workspace this morning. It has no other code in it except trying to create a drawer navigator.
I’ve peeked into AppDelegate.h and it’s already using RCTDelegate instead of UIResponder. Still can’t get past this error. Can someone reopen this issue?
Hey @nikolal
Sure, I cant say for sure what did it, but im pretty sure it was a combination of updating the
AppDelegate.mm
andAppDelegate.h
files.A year or so ago we ejected from an expo app and have somewhat been cleaning up bits and peices ever since.
I based my updates on this 0.72.1 diffApp: https://github.com/react-native-community/rn-diff-purge/tree/version/0.72.1/RnDiffApp
For starters, I noticed we had
AppDelgate.m
not.mm
, not sure if that matters, but that’s what the latest template says it should be.Our
AppDelegate.h
also had some different content, likely from a previous versions standard as I don tthink this is a commonly changed file.I changed ours to match this: https://github.com/react-native-community/rn-diff-purge/blob/version/0.72.1/RnDiffApp/ios/RnDiffApp/AppDelegate.h
Our AppDelegate.mm cotent was also quite different, with a bunch of outdated Flipper setup lines in there, I removed all those as it’s part of framework by default now.
I based our new AppDelegate on this: https://github.com/react-native-community/rn-diff-purge/blob/version/0.72.1/RnDiffApp/ios/RnDiffApp/AppDelegate.mm
Our new AppDelegate.mm is close to this and now looks like
I didnt change anything in React land before it started working, so I think your problem will be around these files too…
Our index.js is stock standard
Once this error cleared, I did have to wrap our app in a
<GestureHandlerRootView style={{ flex: 1 }}>
at the root level to clear a different error, although the docs on this on the software-mansion website were pretty clear,I hope that helps.