react-native-reanimated: App does not compile on Android "compileReleaseJavaWithJavac"

Description

I’m trying to build the app by doing ./gradlew assemblerelease. I now get an error message.

Expected behavior

App builds successfully

Actual behavior & steps to reproduce

App fails to build.

Here is the log:

> Task :react-native-reanimated:compileReleaseJavaWithJavac
/Users/humad/Desktop/tvproject-mobile/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

> Task :react-native-community_datetimepicker:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-haptic-feedback:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-fast-image:compileReleaseJavaWithJavac
Note: [2] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule, com.dylanvann.fastimage.FastImageOkHttpProgressGlideModule]

> Task :unimodules-core:compileReleaseJavaWithJavac
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :react-native-reanimated:compileReleaseJavaWithJavac
/Users/humad/Desktop/tvproject-mobile/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java:11: error: recursive constructor invocation
  public ReanimatedUIImplementation(
         ^

> Task :react-native-firebase_app:compileReleaseJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :react-native-reanimated:compileReleaseJavaWithJavac FAILED
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.
2 errors

> Task :expo-application:compileReleaseJavaWithJavac
Note: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :expo-dev-menu:compileReleaseKotlin
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-menu/android/src/release/java/expo/modules/devmenu/DevMenuManager.kt: (22, 42): Returning type parameter has been inferred to Nothing implicitly. Please, specify type arguments explicitly to hide this warning. Nothing can produce an exception at runtime.
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-menu/android/src/release/java/expo/modules/devmenu/DevMenuManager.kt: (84, 43): The corresponding parameter in the supertype 'DevMenuManagerInterface' is named 'shouldAutoLaunch'. This may cause problems when calling this function with named arguments.

> Task :expo-dev-launcher:compileReleaseKotlin
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/DevLauncherActivity.kt: (31, 25): 'constructor Handler()' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (33, 49): 'constructor TaskDescription(String!, Bitmap!, Int)' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (57, 61): 'FLAG_TRANSLUCENT_STATUS: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (87, 47): 'getter for systemUiVisibility: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (90, 70): 'SYSTEM_UI_FLAG_LIGHT_STATUS_BAR: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (94, 69): 'SYSTEM_UI_FLAG_LIGHT_STATUS_BAR: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (98, 69): 'SYSTEM_UI_FLAG_LIGHT_STATUS_BAR: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (102, 17): 'setter for systemUiVisibility: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (110, 59): 'FLAG_FULLSCREEN: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (111, 61): 'FLAG_FORCE_NOT_FULLSCREEN: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (113, 59): 'FLAG_FORCE_NOT_FULLSCREEN: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (114, 61): 'FLAG_FULLSCREEN: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (126, 23): 'replaceSystemWindowInsets(Int, Int, Int, Int): WindowInsets' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (127, 25): 'getter for systemWindowInsetLeft: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (129, 25): 'getter for systemWindowInsetRight: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/main/java/expo/modules/devlauncher/launcher/configurators/DevLauncherExpoActivityConfigurator.kt: (130, 25): 'getter for systemWindowInsetBottom: Int' is deprecated. Deprecated in Java
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/release/java/expo/modules/devlauncher/DevLauncherController.kt: (92, 20): Parameter 'context' is never used
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/release/java/expo/modules/devlauncher/DevLauncherController.kt: (92, 38): Parameter 'reactNativeHost' is never used
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/release/java/expo/modules/devlauncher/DevLauncherController.kt: (98, 64): Parameter 'cazz' is never used
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/release/java/expo/modules/devlauncher/DevLauncherController.kt: (103, 35): Parameter 'reactActivity' is never used
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/release/java/expo/modules/devlauncher/DevLauncherController.kt: (108, 27): Parameter 'reactActivity' is never used
w: /Users/humad/Desktop/tvproject-mobile/node_modules/expo-dev-launcher/android/src/release/java/expo/modules/devlauncher/DevLauncherController.kt: (108, 57): Parameter 'intent' is never used

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-reanimated:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 56s
512 actionable tasks: 512 executed

Snack or minimal code example

Package versions

name version
react-native 0.63.4
react-native-reanimated 2.3.0-beta.1 (but I’ve also tried with the latest version)
NodeJS 16.14
Xcode N/A
Java openjdk 11.0.11
Gradle 6.3
expo 42 (but I dont use it)

Affected platforms

  • Android
  • iOS
  • Web

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 25 (3 by maintainers)

Most upvoted comments

Fixed it. Use Jdk-17 instead. Jdk 21 is buggy. soon after I switched it started working properly

主工程添加: //解决编译报错

rootProject.getSubprojects().forEach({ project ->
    if ("react-native-reanimated" == project.name) {
        project.tasks.withType(JavaCompile) {
            compileTask ->
                compileTask.dependsOn("applyJavaPatches")
        }
    }
})

Today the issue is active again on our CI… Yesterday all builds were green, but today without any changes builds fails.

Error is now 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.

Hey @Humad 👋 I have just tried to reproduce your issue, but I couldn’t. This issue is because the gradle task applyJavaPatches didn’t start. We replace files during applyJavaPatches to provide backward compatibility. I am not sure why this task didn’t execute in your case. Maybe you have a custom Gradle configuration. Could you provide me a repo with a reproducible example?

Fast fix: You can manually replace this file with this file