Task :expo-modules-core:buildCMakeDebug[x86_64] Bare React Native Error

1k views Asked by At

I am trying to run a React Native application on Android device. Although, Gradle build finishes successfully, but, the app does not build or run. It keeps giving me this weir error:

> Task :expo-modules-core:buildCMakeDebug[armeabi-v7a]
C/C++: ninja: Entering directory `/Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/.cxx/Debug/131e2i41/armeabi-v7a'
C/C++: In file included from /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.cpp:3:
C/C++: In file included from /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.h:5:
C/C++: In file included from /Users/abc/.gradle/caches/transforms-3/af481f74ca2b61c91496ce7d7a53c1e7/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/fbjni.h:21:
C/C++: In file included from /Users/abc/.gradle/caches/transforms-3/af481f74ca2b61c91496ce7d7a53c1e7/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Environment.h:18:
C/C++: In file included from /Users/abc/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:504:
C/C++: /Users/abc/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/memory:4434:5: error: static_assert failed due to requirement 'is_constructible<facebook::react::LongLivedObjectCollection>::value' "Can't construct object in make_shared"
C/C++: /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.cpp:238:37: note: in instantiation of function template specialization 'std::make_shared<facebook::react::LongLivedObjectCollection>' requested here
C/C++: In file included from /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.cpp:3:
C/C++: In file included from /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.h:5:
C/C++: In file included from /Users/abc/.gradle/caches/transforms-3/af481f74ca2b61c91496ce7d7a53c1e7/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/fbjni.h:21:
C/C++: In file included from /Users/abc/.gradle/caches/transforms-3/af481f74ca2b61c91496ce7d7a53c1e7/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Environment.h:18:
C/C++: In file included from /Users/abc/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:504:
C/C++: /Users/jasminderpalsingh/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/memory:2260:46: error: field of type 'facebook::react::LongLivedObjectCollection' has private default constructor
C/C++: /Users/abc/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/memory:2353:42: note: in instantiation of member function 'std::__compressed_pair_elem<facebook::react::LongLivedObjectCollection, 1, false>::__compressed_pair_elem' requested here
C/C++: /Users/abc/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/memory:3628:12: note: in instantiation of function template specialization 'std::__compressed_pair<std::allocator<facebook::react::LongLivedObjectCollection>, facebook::react::LongLivedObjectCollection>::__compressed_pair<std::allocator<facebook::react::LongLivedObjectCollection>, std::__value_init_tag>' requested here
C/C++: /Users/abc/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/memory:4441:26: note: in instantiation of member function 'std::__shared_ptr_emplace<facebook::react::LongLivedObjectCollection, std::allocator<facebook::react::LongLivedObjectCollection>>::__shared_ptr_emplace' requested here
C/C++: /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.cpp:238:37: note: in instantiation of function template specialization 'std::make_shared<facebook::react::LongLivedObjectCollection>' requested here
C/C++: /Users/abc/.gradle/caches/transforms-3/05f8c5110695b559e432038ccd78233f/transformed/jetified-react-android-0.72.0-debug/prefab/modules/react_nativemodule_core/include/react/bridging/LongLivedObject.h:52:3: note: declared private here
C/C++: /Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/MethodMetadata.cpp:40:57: error: too many arguments to function call, expected 3, have 4
C/C++: /Users/abc/.gradle/caches/transforms-3/05f8c5110695b559e432038ccd78233f/transformed/jetified-react-android-0.72.0-debug/prefab/modules/react_nativemodule_core/include/react/bridging/CallbackWrapper.h:34:41: note: 'createWeak' declared here

> Task :expo-modules-core:buildCMakeDebug[armeabi-v7a] FAILED

There are other similar errors for [x86] and [x86_64]. Another error that I am seeing is in MethodMetadata.cpp:

/Users/abc/Documents/React_Native_Apps/app-new/node_modules/expo-modules-core/android/src/main/cpp/MethodMetadata.cpp:40:57: error: too many arguments to function call, expected 3, have 4
/Users/abc/.gradle/caches/transforms-3/05f8c5110695b559e432038ccd78233f/transformed/jetified-react-android-0.72.0-debug/prefab/modules/react_nativemodule_core/include/react/bridging/CallbackWrapper.h:34:41: note: 'createWeak' declared here

I have tried deleting node_modules, clearing cache, ./gradlew clean, every such thing, but, nothing has worked so far.

I am using: "expo": "^48.0.0", "react-native": "~0.72.0", Android Studio Flamingo | 2022.2.1 Patch 1(Tried with Patch 2 too) Device: Macbook M2 Pro

1

There are 1 answers

4
rolling_codes On

I believe you need to upgrade expo to SDK 49 (and any other expo libraries), or later as mentioned in the react-native release notes

If you use Expo, React Native version 0.72 will be supported in the Expo SDK 49 release.

In my case, I had to update both expo and expo-modules-core to fix this build error

npm install expo@latest
npm install expo-modules-core@latest # if you use it
yarn add expo@latest
yarn add expo-modules-core@latest # if you use it