react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

[Android] Java patch doesn't seem to be applied when building from cache

Open Looooong opened this issue 2 years ago • 11 comments

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

  • [x] Android
  • [ ] iOS
  • [ ] Web

Looooong avatar Apr 05 '22 16:04 Looooong

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snippet of code, a snack or a link to a GitHub repository that reproduces the problem?

github-actions[bot] avatar Apr 05 '22 16:04 github-actions[bot]

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or minimal code example section.

github-actions[bot] avatar Apr 05 '22 16:04 github-actions[bot]

Unfortunately I get this error even after I run cd android && ./gradlew clean.

I'm on RN 0.64.2 and 2.6.0.

Any idea what may be going wrong?

jzxchiang1 avatar Apr 09 '22 01:04 jzxchiang1

I'm also having this problem. I've RN 0.63.4 and react-native-reanimated 2.5.0

FabioMFGaspar avatar Apr 11 '22 09:04 FabioMFGaspar

"react-native": "0.63.4", "react-native-reanimated": "^2.4.1",

I have same issue.

cleandevcode avatar Apr 13 '22 19:04 cleandevcode

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!

cleandevcode avatar Apr 15 '22 16:04 cleandevcode

yarn run android

im still facing error

agilbani avatar Apr 28 '22 14:04 agilbani

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

FabioMFGaspar avatar Apr 28 '22 14:04 FabioMFGaspar

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!

Thank you!! Worked for me

kayallapl-zz avatar Apr 28 '22 18:04 kayallapl-zz

I don't get this error anymore after upgrading both React and React Native

react: 16.13.1 -> 17.0.2
react-native: 0.63.4 -> 0.64.3

Probably, for Reanimated 2.5.0, React Native version should be upgraded to 0.64 or newer.

Looooong avatar Apr 29 '22 01:04 Looooong

We use RN version "0.64.2" and REA version "^2.8.0" If I use the old node modules I see this structure in re-animated >

image

But If do yarn install even without changing anything in package.json I see the reanimated-64.aar file not available ?

image

I'm able to work if I use the old node modules and that's possible until I change the package.json. Should I spend my time upgrading the RN version (which is a pain as unimodules are involved) or what else can be done here from reanimated side ?

ratz6 avatar Jul 14 '22 05:07 ratz6

I wish I could solve this.....

fogg4444 avatar Oct 21 '22 00:10 fogg4444

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?

github-actions[bot] avatar Oct 21 '22 00:10 github-actions[bot]

So, do we know why this works? It's about the patching not applying unless you completely re-install? I've had issues pop up with this library for months across various versions of React and React Native. Can't seem to find what the root cause is...

fogg4444 avatar Nov 04 '22 18:11 fogg4444

Same error reproducible for our project on CI for release Android build:

React v18.0.0 React Native v0.69.6 React Native Reanimated: v2.10.0


Task :react-native-reanimated:compileReleaseJavaWithJavac FAILED
/builds/engineering/mobile/live-investing-app/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java:15: error: cannot find symbol
class ReaUiImplementationProvider extends UIImplementationProvider {
                                          ^
  symbol: class UIImplementationProvider
/builds/engineering/mobile/live-investing-app/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java:17: error: method does not override or implement a method from a supertype
  @Override
  ^
/builds/engineering/mobile/live-investing-app/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java:38: error: no suitable constructor found for UIManagerModule(ReactApplicationContext,List<ViewManager>,ReaUiImplementationProvider,int)
    super(
    ^
    constructor UIManagerModule.UIManagerModule(ReactApplicationContext,ViewManagerResolver,int) is not applicable
      (actual and formal argument lists differ in length)
    constructor UIManagerModule.UIManagerModule(ReactApplicationContext,List<ViewManager>,int) is not applicable
      (actual and formal argument lists differ in length)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
FAILURE: Build failed with an exception.

Locally debug and release Android build works fine. Only when we build Android app on CI with cached npm modules it throws an error.

oleksandr-dziuban avatar Nov 04 '22 22:11 oleksandr-dziuban

https://github.com/facebook/react-native/issues/35210

oleksandr-dziuban avatar Nov 05 '22 09:11 oleksandr-dziuban