software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.61k stars 1.26k forks source link

Android build failure v3.12.0 #6076

Closed bhandanyan-nomad closed 3 weeks ago

bhandanyan-nomad commented 1 month ago

Description

Android build failing on 3.12.0:

> Task :react-native-reanimated:compileReleaseJavaWithJavac
/root/repo/node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java:5: error: cannot find symbol
    private void addDevMenuOption(ReactApplicationContext context, DevOptionHandler handler) {
                                  ^
  symbol:   class ReactApplicationContext
  location: class DevMenuUtils
/root/repo/node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java:5: error: cannot find symbol
    private void addDevMenuOption(ReactApplicationContext context, DevOptionHandler handler) {
                                                                   ^
  symbol:   class DevOptionHandler
  location: class DevMenuUtils
/root/repo/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java:85: error: addDevMenuOption(ReactApplicationContext,DevOptionHandler) has private access in DevMenuUtils
    DevMenuUtils.addDevMenuOption(mContext.get(), this::toggleSlowAnimations);
                ^
/root/repo/node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java:7: error: cannot find symbol
    if (context.getApplicationContext() instanceof ReactApplication) {
                                                   ^
  symbol:   class ReactApplication
  location: class DevMenuUtils
/root/repo/node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java:8: error: cannot find symbol
      final DevSupportManager devSupportManager =
            ^
  symbol:   class DevSupportManager
  location: class DevMenuUtils
/root/repo/node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/DevMenuUtils.java:9: error: cannot find symbol
          ((ReactApplication) context.getApplicationContext())
            ^
  symbol:   class ReactApplication
  location: class DevMenuUtils
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.
6 errors

> Task :react-native-reanimated:compileReleaseJavaWithJavac FAILED

Steps to reproduce

Build android

Snack or a link to a repository

n/a

Reanimated version

3.12.0

React Native version

0.72.14

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 1 month ago

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?

ssukru commented 1 month ago

same error on v3.6.2

"react-native-reanimated": "^3.6.2" "react-native": "0.71.15" gradle-7.5.1

efstathiosntonas commented 1 month ago

probably related to: https://github.com/facebook/react-native/pull/44341

ssukru commented 1 month ago

the solution I found on stackoverflow seems to be working for me:

Check in the node_modules folder which version you are installing. If it is not the one in package.json , try installing the corresponding version via npm: npm install react-native-reanimated@3.7.1 . Make sure to delete the react-native-reanimated folder of node_modules before and that the package version is not locked in the package-lock.json/yarn.lock . This solved my issue

gronxb commented 1 month ago

Hi, this pull request can solve it.

6073

Victor-ARC commented 1 month ago

For me, version 3.10.1 is working fine. Version 3.12.0 gives me the error above.

Usmanqayyum109 commented 4 weeks ago

I resolved an issue using the following setup:

React Native version: 0.72.4 react-native-reanimated version: 3.11.0

The solution involves replacing the DevMenuUtils.java file located at _node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/._

Here's the code to use in DevMenuUtils.java:

package com.swmansion.reanimated;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.ReactApplication;
import com.facebook.react.devsupport.interfaces.DevOptionHandler;
import com.facebook.react.devsupport.interfaces.DevSupportManager;

public class DevMenuUtils {

    public static void addDevMenuOption(ReactApplicationContext context, DevOptionHandler handler) {
        // In Expo, `ApplicationContext` is not an instance of `ReactApplication`
        if (context.getApplicationContext() instanceof ReactApplication) {
            final DevSupportManager devSupportManager =
                ((ReactApplication) context.getApplicationContext())
                    .getReactNativeHost()
                    .getReactInstanceManager()
                    .getDevSupportManager();

            devSupportManager.addCustomDevOption(
                "Toggle slow animations (Reanimated)", handler);
        }
    }
}
szydlovsky commented 3 weeks ago

Fixed through https://github.com/software-mansion/react-native-reanimated/pull/6073 and https://github.com/software-mansion/react-native-reanimated/pull/6097 (there had to be a new PR because of monorepo migration, but all credits go to @gronxb). The fix will be available in the next nightly build or in a new stable version (probably 3.13).

Mihai-github commented 3 weeks ago

Issue present in this version also "react-native-reanimated": "^3.5.4"

Mihai-github commented 3 weeks ago

For anyone who needs this fix before the official release use patch-package to apply the changes (https://www.npmjs.com/package/patch-package)

IncrediblePony commented 1 week ago

Issue still persists for us.

Gradle 8.2

{
    "react": "18.2.0",
    "react-native": "0.72.15",
    "react-native-reanimated": "^3.3.0",
}
szydlovsky commented 1 week ago

@Mihai-github @IncrediblePony it got fixed in 3.13.0-rc.2 experimental release. It will be available in the next stable release, most likely 3.13.

jrpn93 commented 3 days ago

I resolved an issue using the following setup:

React Native version: 0.72.4 react-native-reanimated version: 3.11.0

The solution involves replacing the DevMenuUtils.java file located at _node_modules/react-native-reanimated/android/src/reactNativeVersionPatch/ReactHost/72/com/swmansion/reanimated/._

Here's the code to use in DevMenuUtils.java:

package com.swmansion.reanimated;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.ReactApplication;
import com.facebook.react.devsupport.interfaces.DevOptionHandler;
import com.facebook.react.devsupport.interfaces.DevSupportManager;

public class DevMenuUtils {

    public static void addDevMenuOption(ReactApplicationContext context, DevOptionHandler handler) {
        // In Expo, `ApplicationContext` is not an instance of `ReactApplication`
        if (context.getApplicationContext() instanceof ReactApplication) {
            final DevSupportManager devSupportManager =
                ((ReactApplication) context.getApplicationContext())
                    .getReactNativeHost()
                    .getReactInstanceManager()
                    .getDevSupportManager();

            devSupportManager.addCustomDevOption(
                "Toggle slow animations (Reanimated)", handler);
        }
    }
}

@Usmanqayyum109 Thanks, This worked for me!