Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jeanregisser opened this issue Sep 17, 2024 · 12 comments · Fixed by #6553 or #6590
Closed

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

jeanregisser opened this issue Sep 17, 2024 · 12 comments · Fixed by #6553 or #6590
Assignees
Labels
Platform: Android This issue is specific to Android

Comments

@jeanregisser
Copy link
Contributor

jeanregisser commented Sep 17, 2024

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

valora-inc/wallet#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 github-actions bot added Platform: Android This issue is specific to Android Missing repro This issue need minimum repro scenario labels Sep 17, 2024
Copy link

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?

@JavanHuang
Copy link

JavanHuang commented Sep 18, 2024

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 😅

@tjzel tjzel self-assigned this Sep 19, 2024
@0afcode
Copy link

0afcode commented Sep 23, 2024

I am also having this problem. Downgraded to v3.14.0 fixed it

@AlbanW
Copy link

AlbanW commented Sep 24, 2024

I got the same issue with v3.14.0
Here is my dependencies:
"react": "18.2.0", "react-native": "^0.72.3", "react-native-reanimated": "^3.14.0", "react-native-reanimated-carousel": "^3.5.1",
Someone have a solution..?

@tjzel
Copy link
Collaborator

tjzel commented Sep 25, 2024

Just to let you know, there are two wolves inside Android NDKs.

NDK27 wants to use explicit this syntax copy [=, this].

NDK23 says [=, this] is too modern for it.

If you use NDK23 please stay at [email protected] for now since 3.15.2 contains the disallowed syntax.

On release of 3.16.0 we'll make it so both NDKs are happy.

Inside you there are two wolves Meme

@tjzel
Copy link
Collaborator

tjzel commented Sep 25, 2024

Part of our team is OOO right now so it's hard for me to give a timeline on when 3.16.0 would release. If for some reason you need patches from 3.15.3 (they are for Fabric IIRC) let me know and we'll try to release 3.15.4 beforehand.

@JavanHuang
Copy link

I got the same issue with v3.14.0 Here is my dependencies: "react": "18.2.0", "react-native": "^0.72.3", "react-native-reanimated": "^3.14.0", "react-native-reanimated-carousel": "^3.5.1", Someone have a solution..?

You should change your react-native-reanimated version to ~3.14.0. instead of having the caret ^3.14.0, as this might cause npm or yarn to install versions higher than 3.14.0 that are incompatible. with your current react-native version

@sivaranjani07
Copy link

I encountered the same issue after installing the react-native-reanimated. Here's how I resolved it:

1.Included the following line to the babel.config.js file:
plugins: [
'react-native-reanimated/plugin', // This must be the last plugin in the list
],
2.Finally I ran this below command:
npm start -- --reset-cache

@quocXEM
Copy link

quocXEM commented Sep 26, 2024

replace "react-native-reanimated": "~3.15.2", => "3.15.2" and restart

@tjzel tjzel removed the Missing repro This issue need minimum repro scenario label Sep 26, 2024
@tjzel tjzel linked a pull request Sep 27, 2024 that will close this issue
1 task
github-merge-queue bot pushed a commit that referenced this issue Sep 27, 2024
## Summary

Turns out preliminary support for NDK27 in
- #6495

broke support for NDK23. This PR brings back support for NDK23 which is
used in React Native 0.72.

## Test plan

- [ ] All GitHub actions pass.

## Notes

Fixes
- #6512
tjzel added a commit that referenced this issue Oct 1, 2024
Turns out preliminary support for NDK27 in
- #6495

broke support for NDK23. This PR brings back support for NDK23 which is
used in React Native 0.72.

- [ ] All GitHub actions pass.

Fixes
- #6512
@natemartins
Copy link

What worked for me was pinning react-native-reanimated to 3.14.0.

package.json

"react-native": "0.72.15",
"react-native-reanimated": "3.14.0",
"react-native-gesture-handler": "^2.20.0",

android/build.gradle

buildToolsVersion = "34.0.0"
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34
kotlinVersion = "1.8.22"
kotlin_version = "1.8.22"
ndkVersion = "25.1.8937393"

@jeanregisser
Copy link
Contributor Author

Thanks @tjzel for the fix, however we tried to upgrade to 3.15.4 and are still getting similar errors:

src/main/reanimated/CMakeFiles/reanimated.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp.o
  FAILED: src/main/reanimated/CMakeFiles/reanimated.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp.o 
  /home/runner/android-tools/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android24 --sysroot=/home/runner/android-tools/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dreanimated_EXPORTS -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/reanimated/AnimatedSensor -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/reanimated/Fabric -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/reanimated/LayoutAnimations -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/reanimated/NativeModules -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/reanimated/Tools -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/src/main/cpp -I/home/runner/work/wallet/wallet/node_modules/react-native/ReactCommon -I/home/runner/work/wallet/wallet/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule -I/home/runner/work/wallet/wallet/node_modules/react-native/ReactCommon/callinvoker -I/home/runner/work/wallet/wallet/node_modules/react-native/ReactCommon/runtimeexecutor -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/worklets/Registries -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/worklets/SharedItems -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/worklets/Tools -I/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/android/../Common/cpp/worklets/WorkletRuntime -isystem /home/runner/.gradle/caches/transforms-3/482b1c06628a767fcfe1bccefac003f3/transformed/jetified-react-android-0.72.15-release/prefab/modules/folly_runtime/include -isystem /home/runner/.gradle/caches/transforms-3/482b1c06628a767fcfe1bccefac003f3/transformed/jetified-react-android-0.72.15-release/prefab/modules/glog/include -isystem /home/runner/.gradle/caches/transforms-3/482b1c06628a767fcfe1bccefac003f3/transformed/jetified-react-android-0.72.15-release/prefab/modules/jsi/include -isystem /home/runner/.gradle/caches/transforms-3/482b1c06628a767fcfe1bccefac003f3/transformed/jetified-react-android-0.72.15-release/prefab/modules/reactnativejni/include -isystem /home/runner/.gradle/caches/transforms-3/619f88658eb27538a9e94cb228da9bac/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include -isystem /home/runner/.gradle/caches/transforms-3/e330929d8db825c32d4c950df0eab975/transformed/jetified-hermes-android-0.72.15-release/prefab/modules/libhermes/include -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -DREACT_NATIVE_MINOR_VERSION=72 -DREANIMATED_VERSION=3.15.4 -DHERMES_ENABLE_DEBUGGER=0 -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++17 -Wall -Werror -DNDEBUG -DJS_RUNTIME_HERMES=1 -O2 -g -DNDEBUG -fPIC -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_HAVE_XSI_STRERROR_R=1 -std=gnu++17 -MD -MT src/main/reanimated/CMakeFiles/reanimated.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp.o -MF src/main/reanimated/CMakeFiles/reanimated.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp.o.d -o src/main/reanimated/CMakeFiles/reanimated.dir/home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp.o -c /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:210:30: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
    uiScheduler_->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
                               ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:39:37: note: expanded from macro 'COPY_CAPTURE_WITH_THIS'
  #define COPY_CAPTURE_WITH_THIS [ =, this ] // NOLINT (whitespace/braces)
                                      ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:276:30: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
    uiScheduler_->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
                               ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:39:37: note: expanded from macro 'COPY_CAPTURE_WITH_THIS'
  #define COPY_CAPTURE_WITH_THIS [ =, this ] // NOLINT (whitespace/braces)
                                      ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:290:7: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
        COPY_CAPTURE_WITH_THIS
        ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:39:37: note: expanded from macro 'COPY_CAPTURE_WITH_THIS'
  #define COPY_CAPTURE_WITH_THIS [ =, this ] // NOLINT (whitespace/braces)
                                      ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:389:7: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
        COPY_CAPTURE_WITH_THIS
        ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:39:37: note: expanded from macro 'COPY_CAPTURE_WITH_THIS'
  #define COPY_CAPTURE_WITH_THIS [ =, this ] // NOLINT (whitespace/braces)
                                      ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:892:7: error: explicit capture of 'this' with a capture default of '=' is a C++20 extension [-Werror,-Wc++20-extensions]
        COPY_CAPTURE_WITH_THIS
        ^
  /home/runner/work/wallet/wallet/node_modules/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp:39:37: note: expanded from macro 'COPY_CAPTURE_WITH_THIS'
  #define COPY_CAPTURE_WITH_THIS [ =, this ] // NOLINT (whitespace/braces)
                                      ^
  5 errors generated.

@jeanregisser
Copy link
Contributor Author

I've proposed a fix in #6590

github-merge-queue bot pushed a commit that referenced this issue Oct 11, 2024
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->
There was a small typo in #6553 which caused building with c++17 to
still fail.

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->

Build works again with RN 0.72 which uses c++17.

## Notes

- Fixes
#6512 (comment)
- Fixes #6584
tjzel pushed a commit that referenced this issue Oct 11, 2024
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->
There was a small typo in #6553 which caused building with c++17 to
still fail.

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->

Build works again with RN 0.72 which uses c++17.

## Notes

- Fixes
#6512 (comment)
- Fixes #6584
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android
Projects
None yet
9 participants