Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Load Spatialite plugin in Android
I've made an application for Android and I need to use sqlite and spatialite. I built sqlite from sources and I set the following variables:
DEFINES += \ REENTRANT=1 \ SQLITE_THREADSAFE=1 \ SQLITE_ENABLE_FTS3 \ SQLITE_ENABLE_RTREE \ SQLITE_ENABLE_LOAD_EXTENSION \
From this page I took spatialite library but I think that spatialite module is already integrated with sqlite so I'd need to use only libjsqlite, is this right?
On the other hand, when I try to use any of these libraries I get a message about some drivers that are not loaded. First a message that cannot load spatialite extension and then the error about the driver
Cannot load spatialite extension: QSqlError("", "Unable to fetch row", "No query")
QSqlError("", "Driver not loaded", "Driver not loaded")
Reading about this error I found that I need to compile Qt from sources and change some lines to allow loading plugins because it's turn off by default. Is there an easier way to get this? Currently, I'm using the precompiled version of Qt.
Can someone guide me a little bit in this matter?
Something is not clear. Are you trying to build a custom SQLite Qt plugin or do you want to use your custom SQLite library directly in your application ?
Hi @SGaist ! Thanks for your reply. I need to use spatialite (sqlite plugin) in my project. The problem that I found was that Qt doesn't allow to load sqlite plugins by default. Maybe I misunderstand something. I think that I need to build a custom SQLite Qt plugin but I also need to compile SQLite library with those flags that I wrote, isn't it?
I'm not seeing what is the module that is blocking the loading from Spatialite.
Your logic sounds good:
- Custom SQLite build
- Re-build the qsqlite plugin with that custom SQLite library
- Replace the installed plugin with this one.
- Deploy your custom SQLite library with it's plugin alongside
You should start your application with the
QT_DEBUG_PLUGINSenvironment variable set to 1. This will give you more information about why it doesn't load.
Thank you @SGaist !!! I will try it and tell if everything went well!!