Error opening a DB using SQLite bundled with the library in RN mobile app: "Cannot convert null value to object"
I 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 here but get an error at opening the database:
Current behavior
OPEN database: Test.db
LOG SQLite.open({"name":"Test.db","dblocation":"nosync"})
ERROR TypeError: Cannot convert null value to object, js engine: hermes
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
Possible solutions
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.
Environment
I'm using Windows and the RN Android emulator (default script: npm run android) with these package's version:
"dependencies": {
"deprecated-react-native-listview": "^0.0.8",
"react": "18.1.0",
"react-native": "0.70.3",
"react-native-sqlite-storage": "^6.0.1"
},
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,
}
],
}
}
}
}
Having same issue any updates on this?
I have the same problem, apparently it's some problem related to hermes, as the library hasn't had updates for a long time it may be giving problems in the current version of RN because they work in a different way than when the library was kept