gradlew job fails to resolve react-native (monorepo, build already worked on Nov. 21)

Out of a sudden I get an error during gradlew when building our app for android.
It seems, something goes wrong during step Configure project :react-native-reanimated

Versions:
Expo SDK 45
node v16.13.2
react-native-reanimated 2.8.0
expo doctor shows no errors

Modules:

  • expo-application (4.1.0)
  • expo-background-fetch (10.2.0)
  • expo-battery (6.2.0)
  • expo-constants (13.1.1)
  • expo-device (4.2.0)
  • expo-eas-client (0.2.1)
  • expo-file-system (14.0.0)
  • expo-font (10.1.0)
  • expo-intent-launcher (10.2.0)
  • expo-json-utils (0.3.0)
  • expo-keep-awake (10.1.1)
  • expo-localization (13.0.0)
  • expo-manifests (0.3.1)
  • expo-modules-core (0.9.2)
  • expo-notifications (0.15.4)
  • expo-screen-orientation (4.2.0)
  • expo-secure-store (11.2.0)
  • expo-splash-screen (0.15.1)
  • expo-structured-headers (2.2.1)
  • expo-task-manager (10.2.1)
  • expo-updates (0.13.4)
  • expo-web-browser (10.2.1)
  • unimodules-app-loader (3.1.0)
  1. I prepared a bugfix build for our app without changing versions or usage of any expo or reactnative packages. The build of my bugfix build failed
    Build Details — d44991b6-7e25-4e33-8de9-acae78e49b46 — mivao — Expo
    After “Using expo modules …” there is this error message:
[stderr] FAILURE: Build failed with an exception.
[stderr] * Where:
[stderr] Build file '/home/expo/workingdir/build/packages/mobile/node_modules/react-native-reanimated/android/build.gradle' line: 216
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':react-native-reanimated'.
[stderr] > /home/expo/workingdir/build/packages/mobile/node_modules/react-native/package.json (No such file or directory)
[stderr] * Try:
[stderr] > Run with --stacktrace option to get the stack trace.
[stderr] > Run with --info or --debug option to get more log output.
[stderr] > Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 2m 21s
  1. I checked the last successful build from Nov. 21.
    Build Details — 6e6d6ad5-abf6-4eef-8408-88954e6d44ac — mivao — Expo
    Comparing the logs from gradlew I see, the output for :react-native-reanimated should be like
> Configure project :react-native-reanimated
AAR for react-native-reanimated has been found
/home/expo/workingdir/build/node_modules/react-native-reanimated/android/react-native-reanimated-68-jsc.aar
Checking the license for package Android SDK Build-Tools 30.0.2 in /home/expo/Android/Sdk/licenses
License for package Android SDK Build-Tools 30.0.2 accepted.
Preparing "Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)".
"Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" ready.
Installing Android SDK Build-Tools 30.0.2 in /home/expo/Android/Sdk/build-tools/30.0.2
...
  1. I reverted my repo back to the commit that provided the last working build.
    Result was the same error as in 1.
    Build Details — 082251fc-749e-4fb7-8a2e-a061114fe65f — mivao — Expo

[EDIT]
I just noted something in the error logs:

[stderr] A problem occurred evaluating project ':react-native-reanimated'.
[stderr] > /home/expo/workingdir/build/packages/mobile/node_modules/react-native/package.json (No such file or directory)

It is true, there is no package.json at this place.
The project users yarn3 with nmMode: hardlinks-local and nodeLinker: node-modules.
The react-native package lies in node_modules at the project root.

Do you have any idea what could cause this error?

I compared the build logs line by line.
The only difference I could spot between the last time it was working and now:

Last time it worked, the expo worker instance already had node v16.13.2 installed.
Now it comes with v16.18.1 and installs my required v16.13.2 (from eas.json) in step Install Custom Tools.

So it seems there was an update to the worker instances. But I really dont have a clue how that could break my builds.

[EDIT]
I updated the project to node v16.18.1, it made no difference

note that on Build Details — 6e6d6ad5-abf6-4eef-8408-88954e6d44ac — mivao — Expo your git index was dirty (that is what the asterisk indicates, more info when you hover)
image

so it’s possible that you didn’t try the exact same code (maybe the lockfile was different, for example)

the error appears to be related to monorepo configuration and reanimated. it is react-native to be inside of the mobile/node_modules path, and maybe it is actually in the root.

there are some strange checks in the build.gradle for this version of reanimated, in particular the isDeveloperMode function. react-native-reanimated/build.gradle at 64d590991e7205d47663ebb216729b5f43b906c9 · software-mansion/react-native-reanimated · GitHub

you should try getting it building locally and once that works it’ll work on eas build as well. Troubleshooting build errors and crashes - Expo Documentation

Hi Brents

Yes, I know about that asterisk.
Back then, there were uncommitted changes in a different package of my monorepo unrelated to the expo app.
And now, as long as I try to find the build error I don’t commit every try before it shows some progress :wink:

I also suspected some monorepo related error.
On my local env environment, all packages including reanimated and react-natve are installed in the node_modules dir on project root. So I wonder why reanimated tries to import from the package dir.

Maybe I’ll take this as reason to finally upgrade to expo 46, hoping the newer reanimated version wont raise this error …

(Will take some time as I have to get rid of native-base v2 first, doesn’t work with react-native in SDK 46, will report back)

Well, upgrading to expo 46 didn’t bring a solution to my build problems with react-native-reanimated.

At least I finally got rid of some stale dependencies that weren’t compatible with RN 0.69 (because of ViewPropTypes).
I’ve read posts on GitHub and Discord from users that fixed this problem by upgrading react-native-reanimated to the latest version, didn’t change a thing in my case.

But because my remaining dependencies had react-native-reanimated only as optional dependency, I removed it completely. And now my app builds again :smiley:

Thanks for your hint on the strange checks in react-native-reanimated build process.