software-mansion / react-native-reanimated

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

[BUILD ERROR] C++ build system [build] failed while executing #6234

Closed Bayramito closed 1 week ago

Bayramito commented 1 week ago

Description

Cannot build release apk after i upgrade version from 3.10.1 to 3.13.0. The issue is not existing in 3.10.1

I get this error

 /Users/bayram/Desktop/Sorsware/omuzreact/node_modules/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp:250:9: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
          makeNativeMethod("performOperations", NativeProxy::performOperations)
          ^
  /Users/bayram/.gradle/caches/transforms-3/cf752b49e9002612d7c057f80c5fa6c7/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Registration.h:97:85: note: expanded from macro 'makeNativeMethod'
  #define makeNativeMethod(...) FBJNI_MACRO_EXPAND(makeNativeMethodN(__VA_ARGS__, 3, 2)(__VA_ARGS__))
                                                                                      ^
  /Users/bayram/.gradle/caches/transforms-3/cf752b49e9002612d7c057f80c5fa6c7/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Registration.h:96:9: note: macro 'makeNativeMethodN' defined here
  #define makeNativeMethodN(a, b, c, count, ...) makeNativeMethod ## count
          ^
  8 errors generated.
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /Users/bayram/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        /Users/bayram/Desktop/Sorsware/omuzreact/node_modules/react-native-reanimated/android/.cxx/RelWithDebInfo/272h6813/arm64-v8a \
        reanimated
    from /Users/bayram/Desktop/Sorsware/omuzreact/node_modules/react-native-reanimated/android

Steps to reproduce

none

Snack or a link to a repository

https://github.com/Bayramito/reanimated-build-error)

Reanimated version

3.13.0

React Native version

0.72.14

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

szydlovsky commented 1 week ago

Hey @Bayramito we would love some repro (a link to repo or expo snack) so that we could see the error ourselves or help you with the setup in case it was done wrongly

Bayramito commented 1 week ago

Hey @Bayramito we would love some repro (a link to repo or expo snack) so that we could see the error ourselves or help you with the setup in case it was done wrongly

https://github.com/Bayramito/reanimated-build-error

lkinasiewicz commented 1 week ago

Hi, I have upgraded from 3.13.0-rc2 to 3.13.0 and have the same issue. Using react-native-tvos 0.72.6-1.

Bayramito commented 1 week ago

Hi, I have upgraded from 3.13.0-rc2 to 3.13.0 and have the same issue. Using react-native-tvos 0.72.6-1.

Yea, on reproducable RN version is also 0.72...

IceManX93X commented 1 week ago

Hey I have a similar Issue with RN 0.72.15 and reanimated version 3.13.0

It appeared after updating the Target SDK Level of the Android Application to 34 (Also updated Gradle and Build Tools)

[0/2] Re-checking globbed directories...
  [1/5] Building CXX object 

... 
  /Users/sja/Projects/Mobile/xxx/xxx/node_modules/react-native-reanimated/android/src/main/cpp/AndroidUIScheduler.cpp:58:7: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
        makeNativeMethod("initHybrid", AndroidUIScheduler::initHybrid),
        ^
  /Users/sja/.gradle/caches/transforms-3/b5f4192f75b34dfaaee200c23072fe25/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Registration.h:97:85: note: expanded from macro 'makeNativeMethod'
  #define makeNativeMethod(...) FBJNI_MACRO_EXPAND(makeNativeMethodN(__VA_ARGS__, 3, 2)(__VA_ARGS__))
                                                                                      ^
  /Users/sja/.gradle/caches/transforms-3/b5f4192f75b34dfaaee200c23072fe25/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Registration.h:96:9: note: macro 'makeNativeMethodN' defined here
  #define makeNativeMethodN(a, b, c, count, ...) makeNativeMethod ## count
          ^
fabienewill commented 1 week ago

Same for me, using React Native 0.72.10, after switching target sdk from 33 to 34:

i tried rm -rf ~/.gradle, rm -rf node_modules yarn.lock, re install and gradlew clean, same error :/

ArtHerasymov commented 1 week ago

Same for me. Upon further investigation I managed to find the issue, but not sure if that's expected behavior.

https://github.com/software-mansion/react-native-reanimated/commit/b4a8837a3d1f7c9c294edca0776ee4f2e140aed7

Here the flag -Wpedantic was added, without it Android builds properly. Though removing it looks like a hack

Bayramito commented 1 week ago

Same for me. Upon further investigation I managed to find the issue, but not sure if that's expected behavior.

b4a8837

Here the flag -Wpedantic was added, without it Android builds properly.

is everything fine after the build ?

ArtHerasymov commented 1 week ago

Same for me. Upon further investigation I managed to find the issue, but not sure if that's expected behavior. b4a8837 Here the flag -Wpedantic was added, without it Android builds properly.

is everything fine after the build ?

Seems ok, but got to do a bit more testing.

tomekzaw commented 1 week ago

Hi @Bayramito, thanks for opening this issue.

Can you confirm that you're using C++17 for building the C++ part of Reanimated?

I know that this error happens when building with C++14, can you confirm that?

Bayramito commented 1 week ago

Hi @Bayramito, thanks for opening this issue.

Can you confirm that you're using C++17 for building the C++ part of Reanimated?

I know that this error happens when building with C++14, can you confirm that?

On my local setup it might be 14 but not sure, bur i am using Azure as well. It crashes on both places

Bayramito commented 1 week ago
Ekran Resmi 2024-07-09 17 58 05

@tomekzaw

tomekzaw commented 1 week ago

@Bayramito

The easiest way to check this would be to add the following somewhere in Reanimated C++ codebase:

#if __cplusplus != 201703L
#error "Not using C++17"
#endif
achall9 commented 1 week ago

Same issue since upgrading to React Native 0.71.4.

Bayramito commented 1 week ago

@Bayramito

The easiest way to check this would be to add the following somewhere in Reanimated C++ codebase:

#if __cplusplus != 201703L
#error "Not using C++17"
#endif

Ism’t there anything to do to fix it @tomekzaw

rohitmerawat807 commented 1 week ago

Same issue for me as well, My 2 days are wasted because of this error.

React-Native = 0.71.3 "react-native-reanimated": "^3.13.0", Target sdk from 34, not working with 33 also.

Screenshot 2024-07-10 at 12 35 55
sainyanhtay commented 1 week ago

Same for me, after switching target SDK from 33 to 34.

dimaischenko commented 1 week ago

The same for me. Just after upgrading react-native-reanimated from 3.12.1 to 3.13.0 (react-native = 0.73.9)

wzbos commented 1 week ago

app/build.gradle

` android {

afterEvaluate {
    def file = file('../../node_modules/react-native-reanimated/android/CMakeLists.txt')
    if (!file.exists()) {
        println "[Fix-CMakeLists] File not found: ${file}"
        return
    }
    def content = file.text
    def Wpedantic = "-Wpedantic -Werror"
    if (content.contains(Wpedantic)) {
        def modifiedContent = content.replace(Wpedantic, "-Werror")
        file.withWriter('UTF-8') { writer ->
            writer.write(modifiedContent)
        }
        println "[Fix-CMakeLists] Modified ${file}"
    } else {
        println "[Fix-CMakeLists] No changes needed in ${file}"
    }
}

}`

sainyanhtay commented 1 week ago

app/build.gradle

` android {

afterEvaluate {
    def file = file('../../node_modules/react-native-reanimated/android/CMakeLists.txt')
    if (!file.exists()) {
        println "[Fix-CMakeLists] File not found: ${file}"
        return
    }
    def content = file.text
    def Wpedantic = "-Wpedantic -Werror"
    if (content.contains(Wpedantic)) {
        def modifiedContent = content.replace(Wpedantic, "-Werror")
        file.withWriter('UTF-8') { writer ->
            writer.write(modifiedContent)
        }
        println "[Fix-CMakeLists] Modified ${file}"
    } else {
        println "[Fix-CMakeLists] No changes needed in ${file}"
    }
}

}`

It's worked. thanks

Bayramito commented 1 week ago

app/build.gradle

` android {

afterEvaluate {
    def file = file('../../node_modules/react-native-reanimated/android/CMakeLists.txt')
    if (!file.exists()) {
        println "[Fix-CMakeLists] File not found: ${file}"
        return
    }
    def content = file.text
    def Wpedantic = "-Wpedantic -Werror"
    if (content.contains(Wpedantic)) {
        def modifiedContent = content.replace(Wpedantic, "-Werror")
        file.withWriter('UTF-8') { writer ->
            writer.write(modifiedContent)
        }
        println "[Fix-CMakeLists] Modified ${file}"
    } else {
        println "[Fix-CMakeLists] No changes needed in ${file}"
    }
}

}`

Thanks for the effort but i think editing this file in reanimated module and patching it temporarily, is easier task to do

rohitmerawat807 commented 1 week ago

app/build.gradle

` android {

afterEvaluate {
    def file = file('../../node_modules/react-native-reanimated/android/CMakeLists.txt')
    if (!file.exists()) {
        println "[Fix-CMakeLists] File not found: ${file}"
        return
    }
    def content = file.text
    def Wpedantic = "-Wpedantic -Werror"
    if (content.contains(Wpedantic)) {
        def modifiedContent = content.replace(Wpedantic, "-Werror")
        file.withWriter('UTF-8') { writer ->
            writer.write(modifiedContent)
        }
        println "[Fix-CMakeLists] Modified ${file}"
    } else {
        println "[Fix-CMakeLists] No changes needed in ${file}"
    }
}

}`

Where to add it exactly in build.gradle?

Bayramito commented 1 week ago

app/build.gradle ` android {

afterEvaluate {
    def file = file('../../node_modules/react-native-reanimated/android/CMakeLists.txt')
    if (!file.exists()) {
        println "[Fix-CMakeLists] File not found: ${file}"
        return
    }
    def content = file.text
    def Wpedantic = "-Wpedantic -Werror"
    if (content.contains(Wpedantic)) {
        def modifiedContent = content.replace(Wpedantic, "-Werror")
        file.withWriter('UTF-8') { writer ->
            writer.write(modifiedContent)
        }
        println "[Fix-CMakeLists] Modified ${file}"
    } else {
        println "[Fix-CMakeLists] No changes needed in ${file}"
    }
}

}`

Where to add it exactly in build.gradle?

Just open CMakeList.txt in node_modules/react-native-reanimated/android in line 18 remove the keyword -Wpedantic then npx patch-package react-native-reanimated thats it.

But this is a temporary fix,

tomekzaw commented 1 week ago

Should be fixed in https://github.com/software-mansion/react-native-reanimated/pull/6250, will be released in 3.13.1.