-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TurboModule for android is always null #11
Comments
Hey, @PritishSawant in your CalculatorModule. |
Try to return a direct value without promise and clean your project first |
You are right. I wanted you to just confirm that it is working or not. |
Hey @PritishSawant I did try your example. It's working. Here's the code. import {TurboModule, TurboModuleRegistry} from 'react-native'; interface Spec extends TurboModule { isEmulator(): Promise; getMacAddress(): string; // This your example export default TurboModuleRegistry.getEnforcing('MyDeviceInfo'); Java code public abstract class NativeMyDeviceInfoSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { @ReactMethod(isBlockingSynchronousMethod = true) @ReactMethod @ReactMethod(isBlockingSynchronousMethod = true) @ReactMethod JS Implementation |
Try to create a new project. I was facing the similar issue. I don't why but it worked on new project OR reiterate the process. |
Hey @PritishSawant |
@ponikar Thanks will check soon |
@ponikar I cloned your repo and it works perfectly. I decided to make my own new repo based on your repo and my app crash. I don't see any logs on terminal. New repo is here https://github.com/PritishSawant/reactnativenewturbomoduletry I see following error in Android studio
|
@ponikar Thanks your repo helped me to solve the issue. Closing this. Really appreciate your help. I do have following questions
|
I am trying to create a
TurboModule
for android withReactNative v0.69
Following are the steps which I followed for creating
TurboModules
I enabledHermes
andnewArchEnabled
In
gradle.properties
newArchEnabled=true
I created a
js
folder in root of the project and createNativeCalculator.js
In
app/build.gradle
In
java/com/firstapp/newarchitecture/modules
Created
CalculatorModule.java
, fileIn
MainApplication.java
In
getPackages
method added following codeIn
main/jni/Android.mk
include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
In
MainApplicationModuleProvider.cpp
#include <calculator.h>
In
App.js
import NativeCalculator from './js/NativeCalculator';
on Button press I have following code
I tried console logging
NativeCalculator
but I get nullThe entire source code is available here https://github.com/PritishSawant/reactnativeandroidturbomoduleV2
The text was updated successfully, but these errors were encountered: