2

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} )
Serhat
  • 187
  • 1
  • 14
  • 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 [ask] and edit the question post accordingly. – Tsyvarev Jul 01 '22 at 07: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 – Serhat Jul 01 '22 at 08:10

4 Answers4

6

I fixed this issue :

softwareupdate --install-rosetta 
Serhat
  • 187
  • 1
  • 14
  • 1
    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](/help/how-to-answer). – Community Jul 05 '22 at 15:58
2

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.

Vaezman
  • 21
  • 1
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"
      }
    }
  }
GETEM5
  • 37
  • 1
  • 6
1

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

charle
  • 50
  • 5