null is not an object (Evaluating ‘NativeModules[“SQLite”][method]’)

null is not an object (Evaluating ‘NativeModules[“SQLite”][method]’)

The problem “null is not an object (Evaluating ‘NativeModules[“SQLite”][method]’)” is related to SQLite database. When I made the tutorial Example of SQLite Database in React Native everything was well but after some time when React Native version was updated, I faced this issue.

Problem:

While working with SQLite in React Native you can face the problem “null is not an object (Evaluating ‘NativeModules[“SQLite”][method]’)”.

Solution:

Here are the different solutions for the different version of the React Native. Please follow the steps according to the React native version you are working with.

For React Native version > 0.60

If you are working with React Native Version > 0.60 then you have realized that linking of libraries are becoming more better then the old version of React Native. In the old version, we have to do some manual changes for the linking in some cases but in the updated version (0.60+) linking is becoming very easy but in some cases, it creates the problem.

For those who have no idea about what linking is, When we are using the native features like local database gesture handlers etc then we have to make some change in the native projects like Android requires some additional dependencies in the Gradle file and some changes in setting file similarly IOS needs some additional dependencies which can be managed by pod files.

So in the particular case Android is working fine as the addition of dependency is perfect but in case of IOS automatic liking process makes the suitable changes (Creates/Updates) in the pod file but do not installs the pod file so to solve this issue  you need to install the pod file so here is the process which will help you to install pod.

Jump into the Project and then in IOS directory using

now run

and here you will see the updates regarding the installation of linking packaged.

For React Native Version < 0.60

While getting this error I tried to solve it by finding it on the internet but nothing was working. So I followed the following steps and it is solved now.

  1. If you are linking SQLite with react-native link then required changes are not done by the linker so you have to do it on your own. Add the required changes mentioned in the Example of SQLite Database in React Native.
  2. If everything is well and you have already done all the changes then open the following path
    YouSQLiteProject/node_modules/react-native-sqlite-storage/src/android/build.gradle
    and replace

    with

As I was using the react-native:0.58.4 and the defined version was react-native:0.14.+, so just removed the version and added plus(+) for the latest version available and it worked for me. I have also updated compile with implementation because of Gradle 3.+ that Google announced at IO17. If you have no idea about the compile to implementation update then you can visit here, You will find the detailed answer to your question.

Please have a look blow for updated YouSQLiteProject/node_modules/react-native-sqlite-storage/src/android/build.gradle file.

Hope you have also solved your problem. If you have any issue or you want to share something about the topic you can comment below or contact us here. There will be more posts coming soon. Stay tuned!

Hope you liked it. 🙂

4 thoughts on “null is not an object (Evaluating ‘NativeModules[“SQLite”][method]’)”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

For Query / Bug / Problem / Issues we have introduced query trackerKnow More
+