Early JsError: Turbo Module Registry.getEnforcing (...) when trying to build android app using new architecture #220
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This happens when your app is trying to access In this case it generally means there is something going on with your application during the startup. Without a reproducer we can't help you further. |
Beta Was this translation helpful? Give feedback.
-
Hey @SetRedEyes Thanks for providing a reproducer. So the issue you're seeing is because your application is missing the When you create a new application, we create a default However here you're overriding it by providing your own So you will have to do the following.
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html.
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.
# Sets the minimum CMake version required for this project.
cmake_minimum_required(VERSION 3.22.1)
# Declares the project name. The project name can be accessed via ${ PROJECT_NAME},
# Since this is the top level CMakeLists.txt, the project name is also accessible
# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level
# build script scope).
project(appmodules)
# This file includes all the necessary to let you build your application with the New Architecture.
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)
# 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.
#
# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define
# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME}
# is preferred for the same purpose.
#
# In order to load a library into your app from Java/Kotlin, you must call
# System.loadLibrary() and pass the name of the library defined here;
# for GameActivity/NativeActivity derived applications, the same library name must be
# used in the AndroidManifest.xml file.
add_library(Cortex_C_Code_V1 SHARED
Cortex_C_Code_V1.cpp
Cortex_PPG_EEG.cpp
Cortex_PPG_EEG.h
Cortex_PPG_EEG_data.cpp
Cortex_PPG_EEG_private.h
Cortex_PPG_EEG_types.h
pch.cpp
pch.h
rt_nonfinite.cpp
rt_nonfinite.h
rtGetInf.cpp
rtGetInf.h
rtGetNaN.cpp
rtGetNaN.h
rtwtypes.h)
# Specifies libraries CMake should link to your target library. You
# can link libraries from various origins, such as libraries defined in this
# build script, prebuilt third-party libraries, or Android system libraries.
target_link_libraries(Cortex_C_Code_V1
# List libraries link to the target library
android
log)
target_link_libraries(appmodules Cortex_C_Code_V1)
That file will have to live in the same folder of your CMakeLists.txt file. Once you have those two changes, you'll be able to build and run correctly. |
Beta Was this translation helpful? Give feedback.
Hey @SetRedEyes Thanks for providing a reproducer.
So the issue you're seeing is because your application is missing the
libappmodule.so
. That is the default dynamic library used by your app to instantiate React Native.When you create a new application, we create a default
libappmodule.so
for you with all the necessary bits needed to load React Native.However here you're overriding it by providing your own
CMakeLists.txt
file as I see you're compiling some custom C++ code. You can provide your own CMake file, but you need to make sure the libappmodules.so is still produced.So you will have to do the following.
# For more information about using…