5

Got error when I build the project like in the below. I tried so many things but never succeeded. I'm using m1 MacBook. Is this related with this error ?

[CXX1405] exception while building Json A problem occurred starting process 'command '/Users/serhat/Library/Android/sdk/cmake/3.18.1/bin/cmake''

in build.gradle:

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

and this is 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} )
2
  • You need to provide much more details for make the question answerable: the exact project which you build, the exact actions your have performed for build it, the complete error message. Please, (re-)read How to Ask and edit the question post accordingly. Commented Jul 1, 2022 at 7:18
  • can you check again if you have any idea about this error you don't need so much details because it's not feature about the project Commented Jul 1, 2022 at 8:10

5 Answers 5

12

I fixed this issue :

softwareupdate --install-rosetta 
Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
8

The solution for the CMake error while building your application might be to install Rosetta on your Mac. Rosetta is an emulation technology that allows programs designed for Intel processors to run on a Mac with an M1 or M2 chip. Some programs, such as CMake, may not be natively compatible with the M1 or M2 chip, so you need to install Rosetta to ensure that these programs work correctly.

To install Rosetta, you can use the following command:

softwareupdate --install-rosetta

Once you have installed Rosetta, try building your React Native application again. It should work without encountering the errors you mentioned.

I hope this solution helps you.

2 Comments

I was having the same issue on my new Macbook Pro M2 with Sonoma. After installing it, it builds normally, thank you very much!
Same here, its working
3

I have found a simple solution on fixing this problem.All you need is install visual cplus cplus redistribution file. after installting that dependency everything will start to work perfectly. reason Cpp file require some cplus cplus compiler android studio use inbuild microsoft cplus cplus distribution file for this purpose.

I have also created a video guide on explaining it more detail: https://www.youtube.com/watch?v=Xg1wpeq0i_c

Comments

1

I've had a similar issue in the past when using 3.18.1 version of CMake. I'd suggest reinstalling the CMake SDK Tool from SDK Manager within Android Studio.

If it still seems to be referring to 3.18.1 after re-running it could be because a module is directly referring to it somewhere within the build.gradle file.

e.g. I fixed this in expo-modules-core by removing the code below which seemed to be defaulting to an older version of CMake:

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

Comments

1

I meet this quesion,too.

I found my window system is not install the Microsoft Visual C++.

It's ok after I install a lastest vc runtime.

you can found the exe in this link: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.