react-native-nitro-sqlite icon indicating copy to clipboard operation
react-native-nitro-sqlite copied to clipboard

Failed to install react-native-quick-sqlite: React Native is not running on-device. QuickSQLite can only be used when synchronous method invocations (JSI) are possible

Open wogno opened this issue 1 year ago • 6 comments

I install and I get this error, new architecture is enabled

Error: Failed to install react-native-quick-sqlite: React Native is not running on-device. QuickSQLite can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.

"react-native-quick-sqlite": "^8.1.0", "react-native": "0.74.2",

wogno avatar Jun 23 '24 03:06 wogno

import { typeORMDriver } from 'react-native-quick-sqlite'

export const datasource = new DataSource({ type: 'react-native', database: 'mydb.db', location: '.', driver: typeORMDriver, entities: [ User

], synchronize: true, logging: DEV,

});

wogno avatar Jun 23 '24 11:06 wogno

I fill like error is do to typeorm typeORMDriver

wogno avatar Jun 23 '24 11:06 wogno

I get the same issue after updating RN to "0.74.2" from "0.73.4" and using the new architecture.

valceaalexandra avatar Jul 01 '24 08:07 valceaalexandra

I'm experiencing this as well. The suggested workaround didn't work for me sadly.

cjutstraMaxedy avatar Jul 08 '24 12:07 cjutstraMaxedy

Can confirm I'm also receiving this error after upgrading to 0.74 w/ New Arch.

Has anyone managed to resolve it?

kevinranks avatar Jul 18 '24 20:07 kevinranks

I am also facing the same on RN 0.75.2 only when new arch is enabled, on both Android and iOS

Screenshot 2024-09-04 at 18 50 55

There's a similar issue on the MMKV https://github.com/mrousavy/react-native-mmkv/issues/688 I will try to see if any patch from MMKV works here.

pranshuchittora avatar Sep 04 '24 13:09 pranshuchittora

I am also facing the same on RN 0.75.2 only when new arch is enabled, on both Android and iOS

Screenshot 2024-09-04 at 18 50 55 There's a similar issue on the MMKV [mrousavy/react-native-mmkv#688](https://github.com/mrousavy/react-native-mmkv/issues/688) I will try to see if any patch from MMKV works here.

@pranshuchittora did you find any solution to this error? After upgrading to ReactNative 0.76.1 (with New Arch) I got the same issue (after some code fixes). I'm not able to run the app now. I was also checking the MMKV solution, but it is a little more complex than I thought.

smfunder avatar Nov 10 '24 21:11 smfunder

Ok, seems that bypassing the check on the global.nativeCallSyncHook == null it goes better the build / running of the app. Still I'm not able to verify if this is working 100% because I have some other libraries issues when upgrading to RN 0.76.1, but here is my patch file for version 8.2.3 (react-native-quick-sqlite+8.2.3.patch).

NOTE: I'm using:

    buildToolsVersion = "35.0.0"
    minSdkVersion = 26
    compileSdkVersion = 35
    targetSdkVersion = 34
    ndkVersion = "27.2.12479018"
    kotlinVersion = '1.9.24'
diff --git a/node_modules/react-native-quick-sqlite/android/CMakeLists.txt b/node_modules/react-native-quick-sqlite/android/CMakeLists.txt
index b7ba2ff..550c44e 100644
--- a/node_modules/react-native-quick-sqlite/android/CMakeLists.txt
+++ b/node_modules/react-native-quick-sqlite/android/CMakeLists.txt
@@ -20,6 +20,10 @@ file(GLOB_RECURSE cpp_files RELATIVE ${CMAKE_SOURCE_DIR}
   "src/main/cpp/cpp-adapter.cpp"
 )
 
+find_package(ReactAndroid REQUIRED CONFIG)
+find_package(fbjni REQUIRED CONFIG)
+find_library(LOG_LIB log)
+
 add_library(${PACKAGE_NAME} SHARED
   ${cpp_files}
 )
@@ -31,17 +35,11 @@ set_target_properties(
   POSITION_INDEPENDENT_CODE ON
 )
 
-find_package(ReactAndroid REQUIRED CONFIG)
-find_package(fbjni REQUIRED CONFIG)
-find_library(LOG_LIB log)
-
-
 target_link_libraries(
   ${PACKAGE_NAME}
   ${LOG_LIB}
   fbjni::fbjni
   ReactAndroid::jsi
-  ReactAndroid::turbomodulejsijni
-  ReactAndroid::react_nativemodule_core
+  ReactAndroid::reactnative
   android
 )
diff --git a/node_modules/react-native-quick-sqlite/android/build.gradle b/node_modules/react-native-quick-sqlite/android/build.gradle
index 42367f2..32028a1 100644
--- a/node_modules/react-native-quick-sqlite/android/build.gradle
+++ b/node_modules/react-native-quick-sqlite/android/build.gradle
@@ -107,8 +107,8 @@ android {
       "**/libhermes_executor.so",
       "**/libreactnative.so",
       "**/libreactnativejni.so",
-      "**/libturbomodulejsijni.so",
-      "**/libreact_nativemodule_core.so",
+      // "**/libturbomodulejsijni.so",
+      // "**/libreact_nativemodule_core.so",
       "**/libjscexecutor.so"
     ]
   }
diff --git a/node_modules/react-native-quick-sqlite/src/index.ts b/node_modules/react-native-quick-sqlite/src/index.ts
index 1bbcdca..ceef7e4 100644
--- a/node_modules/react-native-quick-sqlite/src/index.ts
+++ b/node_modules/react-native-quick-sqlite/src/index.ts
@@ -25,7 +25,7 @@ if (global.__QuickSQLiteProxy == null) {
   }
 
   // Check if we are running on-device (JSI)
-  if (global.nativeCallSyncHook == null || QuickSQLiteModule.install == null) {
+  if (QuickSQLiteModule.install == null) {
     throw new Error(
       'Failed to install react-native-quick-sqlite: React Native is not running on-device. QuickSQLite can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.'
     )

smfunder avatar Nov 11 '24 02:11 smfunder

Yes, seems to be working the above for me. The only detail that I cannot say if it was before or after is that I disabled the bridgless option for now on RN 0.76.1 because other libraries won't support it. Here is a guide I found on how to do it: https://medium.com/@dwslalit/empowering-react-native-enabling-and-disabling-bridgeless-mode-fad6043d2488

smfunder avatar Nov 11 '24 16:11 smfunder

This should be fixed in https://github.com/margelo/react-native-quick-sqlite/releases/tag/v8.2.4.

Please let me know if this keeps to be an issue, then i can reopen the issue :)

chrispader avatar Nov 13 '24 00:11 chrispader