CXX1405 cmake exception而构建android项目



当我像下面这样构建项目时出现错误。我尝试了很多事情,但从未成功过。我用的是m1 MacBook。

是否与此错误有关?[CXX1405] exception while building Json启动进程'command '/Users/serhat/Library/Android/sdk/cmake/3.18.1/bin/cmake "时出现问题

在build.gradle:

externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}

,这是CmakeList.txt:

# For more information about using CMake with Android Studio,read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source    code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your   APK.
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define   in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log    library
# included in the NDK.
${log-lib} )

我修复了这个问题:

softwareupdate --install-rosetta 

在构建应用程序时CMake错误的解决方案可能是在Mac上安装Rosetta。Rosetta是一种仿真技术,允许为英特尔处理器设计的程序在带有M1或M2芯片的Mac上运行。有些程序,如CMake,可能无法与M1或M2芯片本地兼容,因此您需要安装Rosetta以确保这些程序正常工作。

要安装Rosetta,您可以使用以下命令:

softwareupdate --install-rosetta

一旦你安装了Rosetta,尝试再次构建你的React Native应用程序。它应该不会遇到您提到的错误。

我希望这个解决方案对你有帮助。

我在过去使用3.18.1版本的CMake时有过类似的问题。我建议从Android Studio的SDK管理器中重新安装CMake SDK工具。

如果它在重新运行后似乎仍然引用了3.18.1,这可能是因为模块在构建中的某个地方直接引用了它。gradle文件。

。我在expo-modules-core中修复了这个问题,删除了下面的代码,这些代码似乎默认使用旧版本的CMake:

externalNativeBuild {
cmake {
if (REACT_NATIVE_TARGET_VERSION >= 71) {
path "CMakeLists.txt"
} else {
path "legacy/CMakeLists.txt"
}
}
}

我找到了一个解决这个问题的简单方法。你所需要的就是安装visual cplus的再分发文件。安装该依赖项后,一切都将开始完美地工作。原因Cpp文件需要一些cplus cplus编译器android studio使用inbuild microsoft cplus cplus发行文件。

我还制作了一个视频指南来详细解释它:https://www.youtube.com/watch?v=Xg1wpeq0i_c

相关内容

  • 没有找到相关文章

最新更新