我正在尝试在Android设备上运行React Native应用程序。虽然Gradle构建成功完成,但应用不会构建或运行。它一直给我这个weir错误:
> 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
字符串
[x86]和[x86_64]还有其他类似的错误。我看到的另一个错误是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
型
我试过删除node_modules,清除缓存,./gradlew清理,所有这样的事情,但是,到目前为止都没有工作。
我正在使用:“expo”:“^48.0.0”,“react-native”:“~0.72.0”,Android Studio Flamingo| 2022.2.1补丁1(也尝试了补丁2)器械:Macbook M2 Pro
1条答案
按热度按时间ac1kyiln1#
我相信您需要将expo升级到SDK 49(以及任何其他expo库),或者按照react-native发行说明中提到的更新
如果您使用Expo,Expo SDK 49版本将支持React Native 0.72版本。
在我的例子中,我必须同时更新
expo
和expo-modules-core
来修复这个构建错误个字符