craftzdog / react-native-sqlite-2

SQLite3 Native Plugin for React Native for iOS, Android, Windows and macOS.
Apache License 2.0
379 stars 87 forks source link

undefined is not an object (evaluating 'RNSqlite2.exec') #22

Open codeyourweb opened 6 years ago

codeyourweb commented 6 years ago

I've got a problem when starting an SQL transaction. It also appear on your test application. The database is correctly opened and there is no error before the first SQL transaction. It appears regardless of the number and the type of SQL queries.

undefined is not an object (evaluating 'RNSqlite2.exec')
exec
    C:\wamp64\www\reactor\node_modules\react-native-sqlite-2\src\SQLiteDatabase.js:74:12
runBatch
    C:\wamp64\www\reactor\node_modules\websql\lib\websql\WebSQLTransaction.js:54:32
runAllSql
    C:\wamp64\www\reactor\node_modules\websql\lib\websql\WebSQLTransaction.js:96:11
_checkDone
    C:\wamp64\www\reactor\node_modules\websql\lib\websql\WebSQLTransaction.js:133:12
<unknown>
    C:\wamp64\www\reactor\node_modules\websql\lib\websql\WebSQLDatabase.js:62:4
run
    C:\wamp64\www\reactor\node_modules\immediate\lib\index.js:71:11
nextTick
    C:\wamp64\www\reactor\node_modules\immediate\lib\index.js:42:6
<unknown>
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:262:23
_callTimer
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:154:6
callTimers
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:411:17
__callFunction
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:299:47
<unknown>
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26
__guard
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:262:6
callFunctionReturnFlushedQueue
    C:\wamp64\www\reactor\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17
baynex commented 6 years ago

Edit: Figured out the problem. You will encounter this error if you are using Expo as it is incompatible with this and react-native-sqlite-storage.

MrGurns commented 6 years ago

if you use https://docs.expo.io/versions/latest/sdk/sqlite, it worked for me, although it was slower.

cweilguny commented 6 years ago

In case someone else is dumb like me, and encounters this exact same error when using the package with the Android Emulator: Boy, don't forget to recompile and reinstall the app after installation of the npm package ... else the libraries won't be there #facepalm

lucasvo commented 6 years ago

@MrGurns, are you able to get this module to work with expo or did you completely forgo using react-native-sqlite-2? The reason I'm asking is because I'm trying to get react-native-pouchdb to work in Expo (at least for now I don't want to deal with ditching Expo).

MrGurns commented 6 years ago

@lucasvo I did get it working, but it isn't turned on anymore. I found my issue to be much deeper than the db engine. It turned out to be something with the server configuration. Instead of going through a port for SSL Verification, i ended up coding an endpoint that forwarded the SSL to Couchdb properly.

harikanammi commented 6 years ago

@codeyourweb, Please follow this scenario:- Android Open up android/app/src/main/java/[...]/MainApplication.java Add import dog.craftz.sqlite_2.RNSqlite2Package; to the imports at the top of the file Add new RNSqlite2Package() to the list returned by the getPackages() method Append the following lines to android/settings.gradle:

include ':react-native-sqlite-2'
project(':react-native-sqlite-2').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-2/android')

Insert the following lines inside the dependencies block in android/app/build.gradle: compile project(':react-native-sqlite-2')

Ash-faq commented 5 years ago

How can i use Pre-populated SQLite database from my app

TIA

davidleee commented 5 years ago

For iOS, don't forget to run pod install after running the react-native link xxx command.

ranjithrd commented 3 years ago

Still not able to use this library because of this error. What's the status? Is there any alternative to the library if this is not being maintained?

rdaigle007 commented 2 years ago

Same here, not working. And using Expo (hence not Cocoa pods I think), therefore "pod install" mentioned above is not appropriate I think.

I'm still getting the "null is not an object (evaluating RNSqlite2.exec)" after doing "npx react-native link pouchdb-adapter-react-native-sqlite" as mentioned in related thread https://github.com/craftzdog/pouchdb-adapter-react-native-sqlite/issues/5

tronglv92 commented 2 years ago

still not working

jwallet commented 1 year ago

So I had the same issue, the issue comes from using expo go, if you build your source using npx expo run:android|ios and then use a dev-client npx expo start --dev-client this issue will not come up, in a managed or in bare workflow. even if you use expo-sqlite-storage