TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes
- I got this error "TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes" on IOS.
- Someone please help me!
"react-native": "0.70.1"
I solved it by adding the podscpec. like this.
require "json" package = JSON.parse(File.read(File.join(dir, "package.json"))) Pod::Spec.new do |s| s.name = 'RNBluetoothEscposPrinter' s.version = package['version'] s.summary = package['description'] s.author = 'januslo' s.homepage = 'https://github.com/januslo/react-native-bluetooth-escpos-printer’' s.license = package['license'] s.platform = :ios, '9.0' s.source = { :git => 'https://github.com/januslo/react-native-bluetooth-escpos-printer”, :tag => “#{s.version}”'} s.source_files = "ios/**/*.{h,c,m,swift}" s.requires_arc = true s.dependency "React" end
Also after that, in the file RNBluetoothEscposPrinter.m of the module I changed the import to #import "ZXingObjC.h"
I hope this solve your problem as id did for me
Hello @eduardobda , i have counter the same error, where should i put the code? and can you share the change code or screenshot of your podscpec?
Thanks
Hello @wongmalesan In the node_modules folder go to the react-native-escpos-printer folder, in there you have to create RNBluethoothEscposPrinter.podspec, then in the same module look for the ios folder to edit the RNBluetoothManager.m to change an import to #import "ZXingObjC.h" insted of "#import "ZXingObjC/ZXingObjC.h"" If you have any question you can reply to this and I will check it as soon as I can
@eduardobda not able to solve the issue by the above solution still getting the error
@tngone-aashique @eduardobda Hi! Is there any solution to this problem? Any other working library?
@tngone-aashique @eduardobda Hi! Is there any solution to this problem? Any other working library?
#add this file to nodemodules > react-native-bluetooth-escpos-printer>android>build.gradle file
buildscript { repositories { google() jcenter { url "https://jcenter.bintray.com/" } maven {url "https://repo.spring.io/plugins-release/"} mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } }
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
apply plugin: 'com.android.library'
android { compileSdkVersion 27 buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
sourceSets {
main {
aidl.srcDirs = ['src/main/java']
}
}
}
repositories { jcenter { url "https://jcenter.bintray.com/" } maven {url "https://repo.spring.io/plugins-release/"} mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } }
dependencies { // compile fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.facebook.react:react-native:+' // From node_modules implementation group: 'com.android.support', name: 'support-v4', version: '27.0.0' implementation "com.google.zxing:core:3.3.0" }
#change open node_modules\react-native-bluetooth-escpos-printer\android\src\main\java\cn\jystudio\bluetooth\RNBluetoothManagerModule.java and replace
import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; to
import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat;
Pod::Spec.new do |s|
i got same error bro can you please help me ERROR TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes
@tngone-aashique same error after tried your settings not fixed as well
ERROR TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and
AppRegistry.registerComponentwasn't called., js engine: hermes
packege.json "expo": "~51.0.22", "react-native-bluetooth-escpos-printer": "^0.0.5",
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
buildscript {
repositories { google() jcenter { url "https://jcenter.bintray.com/" } maven {url "https://repo.spring.io/plugins-release/"} mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } }
dependencies { classpath 'com.android.tools.build:gradle:3.1.4' } }
apply plugin: 'com.android.library'
android { compileSdkVersion 27 buildToolsVersion "27.0.3"
defaultConfig { minSdkVersion 16 targetSdkVersion 24 versionCode 1 versionName "1.0" } lintOptions { abortOnError false } sourceSets { main { aidl.srcDirs = ['src/main/java'] } } }
repositories { jcenter { url "https://jcenter.bintray.com/" } maven {url "https://repo.spring.io/plugins-release/"} mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } }
dependencies { // compile fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.facebook.react:react-native:+' // From node_modules implementation group: 'com.android.support', name: 'support-v4', version: '27.0.0' implementation "com.google.zxing:core:3.3.0" }
Thank you for your response regarding this issue.
I'm developing a mobile application using Expo, created with the command
npx create-expo-app. I've been struggling with this error for the past
two months and would appreciate your help in resolving it when you have
some free time.
i will be waiting for your reply
On Thu, 5 Sept 2024 at 14:31, Muhammad Umar @.***> wrote:
@tngone-aashique https://github.com/tngone-aashique same error after tried your settings not fixed as well
ERROR TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:
- Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
- A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes
packege.json "expo": "~51.0.22", "react-native-bluetooth-escpos-printer": "^0.0.5",
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
buildscript {
repositories { google() jcenter { url "https://jcenter.bintray.com/" } maven {url "https://repo.spring.io/plugins-release/"} mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } }
dependencies { classpath 'com.android.tools.build:gradle:3.1.4' } }
apply plugin: 'com.android.library'
android { compileSdkVersion 27 buildToolsVersion "27.0.3"
defaultConfig { minSdkVersion 16 targetSdkVersion 24 versionCode 1 versionName "1.0" } lintOptions { abortOnError false } sourceSets { main { aidl.srcDirs = ['src/main/java'] } } }
repositories { jcenter { url "https://jcenter.bintray.com/" } maven {url "https://repo.spring.io/plugins-release/"} mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com' } }
dependencies { // compile fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.facebook.react:react-native:+' // From node_modules implementation group: 'com.android.support', name: 'support-v4', version: '27.0.0' implementation "com.google.zxing:core:3.3.0" }
— Reply to this email directly, view it on GitHub https://github.com/januslo/react-native-bluetooth-escpos-printer/issues/209#issuecomment-2330986865, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB2YV6QA4QBNEZTTFAYIRM3ZVAMXPAVCNFSM6AAAAAARUE6E2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZQHE4DMOBWGU . You are receiving this because you commented.Message ID: <januslo/react-native-bluetooth-escpos-printer/issues/209/2330986865@ github.com>
-- If you wish to opt out from our emails, please click here https://docs.google.com/forms/d/e/1FAIpQLSeUD2dPH-WmUjH6Kj82OJtpNEgfxxbopcoLyZDbLpQdUlKsFQ/viewform?usp=sf_link* to Unsubscribe.*
@balajigundluru Try to Run Your Project Using this: npx expo run:android
I kindly request Can you please help
On Mon, 9 Sep, 2024, 7:50 am Muhammad Umar, @.***> wrote:
@balajigundluru https://github.com/balajigundluru Try to Run Your Project Using this: npx expo run:android
— Reply to this email directly, view it on GitHub https://github.com/januslo/react-native-bluetooth-escpos-printer/issues/209#issuecomment-2336983141, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB2YV6S4HTKSU56Y2EA2QK3ZVUAWNAVCNFSM6AAAAAARUE6E2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWHE4DGMJUGE . You are receiving this because you were mentioned.Message ID: <januslo/react-native-bluetooth-escpos-printer/issues/209/2336983141@ github.com>
-- If you wish to opt out from our emails, please click here https://docs.google.com/forms/d/e/1FAIpQLSeUD2dPH-WmUjH6Kj82OJtpNEgfxxbopcoLyZDbLpQdUlKsFQ/viewform?usp=sf_link* to Unsubscribe.*