I'm using react-native-sqlite-storage, wanted to use JSON Functions And Operators and after reading the issues I found that I need to use the Android native SQLite #480. Then I changed the react-native.config.js in order to use SQLite bundled with the library. Make some adjustments to run the test example given in the docs but get an error at opening the database:
OPEN database: Test.db
LOG SQLite.open({"name":"Test.db","dblocation":"nosync"})
ERROR TypeError: Cannot convert null value to object, js engine: hermes
I'm using Windows and the RN Android emulator (default script: npm run android) with these package's versions:
"dependencies": {
"deprecated-react-native-listview": "^0.0.8",
"react": "18.1.0",
"react-native": "0.70.3",
"react-native-sqlite-storage": "^6.0.1"
},
I'll like to upload the stack trace but I don't know how to extract it from the device. A few steps from the stack outputed in the device, all of them related to sqlite.core.js file:
1 --- plugin.exec
2 --- SQLitePlugin.prototype.open
3 --- SQLitePlugin
4 --- argsArray$argument_0
I don't know if it's the function itself (openDatabase) that doesn't recognize the args, if I have to use another function or it's due to I didn't pre-populate the db by copying it to a specific folder.
react-native.config.js
module.exports = {
dependency: {
platforms: {
ios: {
project: './platforms/ios/SQLite.xcodeproj'
},
/*
// default config
android: {
sourceDir: './platforms/android'
},
*/
// changed
android: {
sourceDir: "../node_modules/react-native-sqlite-storage/platforms/android-native",
packageImportPath: "import io.liteglue.SQLitePluginPackage;",
packageInstance: "new SQLitePluginPackage()"
},
windows: {
sourceDir: './platforms/windows',
solutionFile: 'SQLitePlugin.sln',
projects: [
{
projectFile: 'SQLitePlugin/SQLitePlugin.vcxproj',
directDependency: true,
}
],
}
}
}
}
I encountered this error also. For my case, it was just an operations sequence issue. This error occurred when I started the APP before installing the react-native-sqlite-storage package. When I restarted the APP, this error disappeared.
Examples for reference: https://blog.logrocket.com/using-sqlite-with-react-native/ https://aboutreact.com/example-of-sqlite-database-in-react-native/