I created a dynamic Qt library that uses Qt SQL to open a SQLite database, but I get this error:
QSqlDatabase: QSQLITE driver not loaded QSqlDatabase: available drivers:
The DLL works fine as part of the Qt application for Android, however I need to use it through JNI from an existing Java application developed in Eclipse.
This is the shortest code example that reproduces the problem. I load the library from Java and call its init() method:
System.loadLibrary("plugins_sqldrivers_libqsqlite"); System.loadLibrary("Qt5Sql"); System.loadLibrary("MyQtLib"); MyQtLib.init();
And inside the Qt library, I just call QSqlDatabase :: addDatabase ():
JNIEXPORT void JNICALL Java_test_MyQtLib_foo(JNIEnv *, jclass) {
Since the QSQLITE driver not loaded error is QSQLITE driver not loaded , and the Qt library works inside the Qt application, I assume that Qt does some initialization, which I am missing.
But this did not fix the error, so there must be something else. Typically, a Qt application will use QtApplication.java and QtActivity.java to do some initialization, so they should do something else that I do not.
c ++ android eclipse qt
sashoalm
source share