software-mansion / react-native-reanimated

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

Android build failing with `react-native-reanimated` 3.15.2 (RN 0.72.15, NDK 23) #6512

Open jeanregisser opened 2 days ago

jeanregisser commented 2 days ago

Description

Hey, we got the following compile errors on Android trying to upgrade react-native-reanimated from v3.15.1 to v3.15.2.

We use the following SDK/NDK versions, with React Native 0.72.15.

ext {
    buildToolsVersion = "34.0.0"
    minSdkVersion = 24
    compileSdkVersion = 34
    targetSdkVersion = 34
    supportLibVersion = "31.0.0"
    kotlinVersion = "1.9.20"
    // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
    ndkVersion = "23.1.7779620"
}

Note: I saw #6466, but compilation was working for us with v3.15.1.

  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:198:34: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
    uiScheduler_->scheduleOnUI([=, this] {
                                   ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:264:34: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
    uiScheduler_->scheduleOnUI([=, this] {
                                   ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:278:11: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
        [=, this] { eventHandlerRegistry_->unregisterEventHandler(id); });
            ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:374:34: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
    uiScheduler_->scheduleOnUI([=, this]() {
                                   ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:881:11: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
        [=, this](int keyboardState, int height) {
            ^
  5 errors generated.
  [29/37] Building CXX object src/main/reanimated/CMakeFiles/reanimated.dir/__/cpp/AndroidUIScheduler.cpp.o
  [30/37] Building CXX object src/main/worklets/CMakeFiles/worklets.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp.o
  [31/37] Building CXX object src/main/reanimated/CMakeFiles/reanimated.dir/__/cpp/JNIHelper.cpp.o
  [32/37] Building CXX object src/main/reanimated/CMakeFiles/reanimated.dir/__/cpp/LayoutAnimations.cpp.o
  [33/37] Building CXX object src/main/reanimated/CMakeFiles/reanimated.dir/__/cpp/OnLoad.cpp.o
  [34/37] Building CXX object src/main/reanimated/CMakeFiles/reanimated.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/Tools/UIRuntimeDecorator.cpp.o
  [35/37] Building CXX object src/main/reanimated/CMakeFiles/reanimated.dir/__/cpp/NativeProxy.cpp.o
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /home/runner/android-tools/cmake/3.18.1/bin/ninja \
        -C \
        /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/.cxx/RelWithDebInfo/83iy3p31/arm64-v8a \
        reanimated \
        worklets
    from /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android

* 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.

Steps to reproduce

  1. upgrade react-native-reanimated from v3.15.1 to v3.15.2

Snack or a link to a repository

https://github.com/valora-inc/wallet/pull/6015

Reanimated version

3.15.2

React Native version

0.72.15

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Release app & production bundle

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 2 days 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?

Dexter0805 commented 1 day ago

Facing the same issue. Following SDK/NDK versions

ext { buildToolsVersion = "33.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33

    // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
    ndkVersion = "23.1.7779620"
}
JavanHuang commented 1 day ago

I encountered the same error log as well while upgrading react-native from 0.71.19 to 0.72.17, where I'm attempting to update to the latest few versions of react-native-reanimated-carousel and @gorhom/bottom-sheet as well. This is a major blocker in trying to upgrade react-native to 0.72.17.

// android/build.gradle
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 27
        compileSdkVersion = 34
        targetSdkVersion = 34
        androidXBrowser = "1.5.0"

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
        // Default gradle v8.0.1 is having problems with Kotlin v1.8.10 for react-native v0.72.x
        kotlinVersion = "1.9.0"
    }
// package.json
    "@gorhom/bottom-sheet": "~4.6.4",
    "react-native": "0.72.17",
    "react-native-reanimated": "~3.15.2",
    "react-native-reanimated-carousel": "~3.5.1",

EDIT: A temporary solution will be to bump react-native-reanimated back to 3.14.0 as running an Android build works without any error. I guess we gotta wait for the fix in a newer version đŸ˜…