Include TurboModule in existing React Native App

60 views Asked by At

I wanted to achieve similar things as to this post, to have my turbomodules (Java Turbomodules) defined part of my app (Android App only), and I followed the instructions as per the author,

  • Followed Turbomodules instructions, but instead of a separate package, defined in the same App, and only followed the Android part of instruction
  • Followed instruction on post instruction, and add Onload.cpp and CMakeLists.txt and also updated app build.gradle

and I was able to get the app to compile. I can see codegen generated code is under android/app/build/generated/source/codegen, with following folder structure

codegen
├── java
│   └── com
│       └── rtncalculator
│           └── NativeCalculatorSpec.java
├── jni
│   ├── Android.mk
│   ├── CMakeLists.txt
│   ├── RTNCalculator-generated.cpp
│   ├── RTNCalculator.h
│   └── react
│       └── renderer
│           └── components
│               └── RTNCalculator
│                   ├── ComponentDescriptors.h
│                   ├── EventEmitters.cpp
│                   ├── EventEmitters.h
│                   ├── Props.cpp
│                   ├── Props.h
│                   ├── ShadowNodes.cpp
│                   └── ShadowNodes.h
└── schema.json

However, once the build finishes, the build folder will be removed. Also at runtime, when I am trying to access the module defined, it will give following errors:

 ERROR  Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RTNCaculator' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes 

Could someone provide some ideas of what could be wrong

0

There are 0 answers