react-native-reanimated
react-native-reanimated copied to clipboard
Build error after upgrading to RN 0.70.2
Description
After upgrading to 0.70.2 I'm seeing the build error below
It looks like a path problem notice
/home/johnf/work/gladly/mobile/node_modules/react-native-reanimated/mobile/node_modules/react-native/package.json
has an extra mobile in it after react-native-reanimated
> Configure project :react-native-firebase_messaging
:react-native-firebase_messaging package.json found at /home/johnf/work/gladly/mobile/node_modules/@react-native-firebase/messaging/package.json
:react-native-firebase_app package.json found at /home/johnf/work/gladly/mobile/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_messaging:firebase.bom using default value: 30.5.0
:react-native-firebase_messaging package.json found at /home/johnf/work/gladly/mobile/node_modules/@react-native-firebase/messaging/package.json
:react-native-firebase_messaging:version set from package.json: 14.12.0 (14,12,0 - 14012000)
:react-native-firebase_messaging:android.compileSdk using custom value: 33
:react-native-firebase_messaging:android.targetSdk using custom value: 33
:react-native-firebase_messaging:android.minSdk using custom value: 23
:react-native-firebase_messaging:reactNativeAndroidDir /home/johnf/work/gladly/mobile/node_modules/react-native/android
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 executed
FAILURE: Build failed with an exception.
* Where:
Build file '/home/johnf/work/gladly/mobile/node_modules/react-native-reanimated/android/build.gradle' line: 135
* What went wrong:
A problem occurred evaluating project ':react-native-reanimated'.
> /home/johnf/work/gladly/mobile/node_modules/react-native-reanimated/mobile/node_modules/react-native/package.json (No such file or directory)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 -PreactNativeDebugArchitectures=x86_64 -PreactNativeArchitectures=x86_64
FAILURE: Build failed with an exception.
* Where:
Build file '/home/johnf/work/gladly/mobile/node_modules/react-native-reanimated/android/build.gradle' line: 135
* What went wrong:
A problem occurred evaluating project ':react-native-reanimated'.
> /home/johnf/work/gladly/mobile/node_modules/react-native-reanimated/mobile/node_modules/react-native/package.json (No such file or directory)
Steps to reproduce
- Upgrade to RN 0.70.2
- yarn android
Snack or a link to a repository
N/A
Reanimated version
3.0.0.rc2
React Native version
0.70.2
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
Android emulator
Device model
No response
Acknowledgements
Yes
Hey! 👋
The issue doesn't seem to contain a minimal reproduction.
Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?
Hey, thanks for reporting this issue. Reanimated 2.10 doesn't work properly in monorepos on Android. Do you use one? If We really hope to get this fixed soon and released in 2.11.
@tomekzaw I'm using v3 and I'm not using a monorepo.
I found another issue after upgrading to reanimated 2.10.0 and react-native 0.70.2 (previously using reanimated 2.9.1 and react-native 0.69.5):
:react-native-reanimated:compileDebugJavaWithJavac FAILED
/my-app/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java:65: error: cannot find symbol
rootView.getRootView().findViewById(com.swmansion.reanimated.R.id.action_bar_root);
^
symbol: variable id
location: class R
/my-app/node_modules/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java:144: error: cannot find symbol
getRootView().getRootView().findViewById(com.swmansion.reanimated.R.id.action_bar_root);
^
symbol: variable id
location: class R
Is there any extra step should be followed for upgrading to reanimated 2.10.0 @tomekzaw ?
edit: unfortunately, can't repro in new RN project with 0.70.2
We have just published 2.11.0 which hopefully resolves this issue: https://www.npmjs.com/package/react-native-reanimated/v/2.11.0
No, it does not resolve it for me (version 2.11.0). I had to patch it myself.
build.gradle:
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
for me it works with:
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../../node_modules/react-native")
but now pod install does not work, as it finds two versions of react-native-reanimated.
[!] Invalid `Podfile` file:
[!] Invalid `RNReanimated.podspec` file: [Reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected
Conflict between:
- /Users/abc/Documents/Develop/bla/node_modules/react-native-reanimated
- /Users/abc/Documents/Develop/bla/app/node_modules/react-native-reanimated
.
# from /Users/abci/Documents/Develop/bla/app/node_modules/react-native-reanimated/RNReanimated.podspec:6
# -------------------------------------------
# config = find_config()
> assert_no_multiple_instances(config)
#
# -------------------------------------------
.
# from /Users/aari/Documents/Develop/barmer-frontends/app/ios/Podfile:12
# -------------------------------------------
# target 'baseapp' do
> config = use_native_modules!
#
# -------------------------------------------
@Sub-Zero-1, what's your setup?
Instead of patching build.gradle, you can override the path by setting environmental variable REACT_NATIVE_NODE_MODULES_DIR.
@tomekzaw I did it. First it solved it, but later on it did not work anymore and retried it multiple times. I don't know why, but does not matter to me as the patch works, but now I have the multiple version conflict with 2.11.0 while pod install. I don't have the multiple version problem with the 2.10.0 so I will now try to adapt the 2.10.0 with the build gradle of the 2.11.0 including my patch as I need to upgrade to RN 0.70.3. Monorepo setup. pozdrawiam
Maybe this helps someone:
I tried to use 2.10.0, but I am using a monorepo, so I got the problem mentioned here from thread starter. Then I updated to 2.11.0 and I got the same error. I patched the version (with help of patch-package) with my specific path, but differently then mentioned in my thread before.
- def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", "../../../../node_modules/react-native")
The option with setting REACT_NATIVE_NODE_MODULES_DIR environment variable mentioned by @tomekzaw did not work for me, or I did it wrong. It would be nice to get an actual example how to do that. I tried with:
def REACT_NATIVE_NODE_MODULES_DIR = "../../../../node_modules/react-native" in build.gradle, but somehow it could not read it or it also searched in a wrong path for the build.gradle of my project?!. Maybe I did it wrong?
Then I could build Android and start the App. On iOS I had to do a pod install, but it failed with multiple version conflict, which I did not have with version 2.10.0.
Therefore, I installed version 2.10.0 and replaced the node_modules/react-native-reanimated/android/build.gradle with the build.gradle from version 2.11.0 and of course adapted the path like mentioned above. Then I could run pod install and the App worked on Android and iOS.
@Sub-Zero-1 def REACT_NATIVE_NODE_MODULES_DIR = ... won't work. You need to set environment variable and make sure it's actually used when building the app.
Getting the same issue, also not using a monorepo
@tomekzaw I'm still seeing this in 3.0.0-rc3 for RN 0.70.4
From what I can tell this is due to the following
def isDeveloperMode() {
// developer mode, to run Example app
return file("$projectDir/../node_modules/react-native/package.json").exists()
}
def resolveReactNativeDirectory() {
if (isDeveloperMode()) {
return file("$projectDir/../${getPlaygroundAppName()}/node_modules/react-native")
}
return file("$projectDir/../../react-native")
}
When isDeveloperMode returns true then resolveReactNativeDirectory injects the app name, in my case mobile into the path.
If I hard code isDeveloperMode to false, everything builds fine.
Does isDeveloperMode exist just for the example app, or is it supposed to be true for dev builds?
This is fixed in 3.0.0-rc.4