react-native-reanimated: [Android] Java patch doesn't seem to be applied when building from cache

Description

Since I upgraded to version 2.5.0, whenever I change a dependency not related to react-native-reanimated and start an Android build from existing cache, the ReanimatedUIImplementation.java doesn’t seem to be patched and will result in the following error:

...\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\layoutReanimation\ReanimatedUIImplementation.java:13: error: cannot find symbol 
      ViewManagerResolver viewManagerResolver,
      ^
  symbol:   class ViewManagerResolver
  location: class ReanimatedUIImplementation

Cleaning Android build and re-building from scratch does work. However, this means that our CI cannot rely on Android build cache anymore.

Expected behavior

I should be able to re-build sucessfully from cache whenever Android project or dependency changes.

Actual behavior & steps to reproduce

Snack or minimal code example

Package versions

name version
react-native 0.63.4
react-native-reanimated 2.5.0
NodeJS 14.17.0
Xcode
Java 1.8
Gradle 4.1.2
expo

Affected platforms

  • Android
  • iOS
  • Web

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16

Most upvoted comments

I fixed this way.

yarn remove react-native-reanimated yarn add react-native-reanimated@^2.4.1 yarn run android

It worked like a charm!

I manage to fix this by updating the React, react-native and babel/core versions

react: 16.13.1 -> 17.0.2 react-native: 0.63.4 -> 0.66.1 @babel/core: ^7.8.4 -> ^7.12.9

I think that only updating react might solve it but I updated the 3