QSqlDatabase: QSQLITE driver not loaded
-
I am building android app and getting followin error
QSqlDatabase: QSQLITE driver not loaded
The code build builds and run fine as a desktop application
Below is the full error trace
Starting remote process.I art : Late-enabling -Xcheck:jni
W System : ClassLoader referenced unknown path:
I QtCore : Start
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libQt5Gui.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libQt5Widgets.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libQt5Charts.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libQt5AndroidExtras.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libQt5Bluetooth.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libQt5Sql.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/platforms/android/libqtforandroid.so: unsupported flags DT_FLAGS_1=0x81
I Qt : qt start
I art : Do partial code cache collection, code=10KB, data=27KB
I art : After code cache collection, code=10KB, data=27KB
I art : Increasing code cache capacity to 128KB
W linker : /data/app/org.qtproject.example.splinechart-1/lib/arm/libsplinechart.so: unused DT entry: type 0xf arg 0x73b4
W : (null):0 ((null)): QSqlDatabase: QSQLITE driver not loaded
W : (null):0 ((null)): QSqlDatabase: available drivers:
W : (null):0 ((null)): QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
D : ../splinechart/devicedata.cpp:55 (DeviceData::DeviceData(QObject*)): Error: connection with database fail
I Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8974_LA.BF.1.1.3_RB1__release_AU (I741a3d36ca)
I Adreno-EGL: OpenGL ES Shader Compiler Version: E031.29.00.00
I Adreno-EGL: Build Date: 04/04/16 Mon
I Adreno-EGL: Local Branch: mybranch19053788
I Adreno-EGL: Remote Branch: quic/LA.BF.1.1.3_rb1.12
I Adreno-EGL: Local Patches: NONE
I Adreno-EGL: Reconstruct Branch: NOTHING
I OpenGLRenderer: Initialized EGL, version 1.4
D OpenGLRenderer: Swap behavior 1
W Adreno-ES20: <get_gpu_clk:229>: open failed: errno 13
W : (null):0 ((null)): WARNING: QApplication was not created in the main() thread.
W libsplinechart.so: (null):0 ((null)): QSqlQuery::exec: database not open
W libsplinechart.so: (null):0 ((null)): QSqlQuery::exec: database not open
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqgif.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqicns.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqico.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqjpeg.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqtga.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqtiff.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqwbmp.so: unsupported flags DT_FLAGS_1=0x81
W linker : /data/data/org.qtproject.example.splinechart/qt-reserved-files/plugins/imageformats/libqwebp.so: unsupported flags DT_FLAGS_1=0x81
W libsplinechart.so: (null):0 ((null)): QSqlDatabase: QSQLITE driver not loaded
W libsplinechart.so: (null):0 ((null)): QSqlDatabase: available drivers:
W libsplinechart.so: (null):0 ((null)): QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
W libsplinechart.so: (null):0 ((null)): QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
D libsplinechart.so: ../splinechart/devicedata.cpp:55 (DeviceData::DeviceData(QObject*)): Error: connection with database fail
W libsplinechart.so: (null):0 ((null)): qt.bluetooth: Connecting to port is not supported
I libsplinechart.so: ../splinechart/devicedata.cpp:190 (int DeviceData::syncDeviceData(bool)): State 3
W libsplinechart.so: (null):0 ((null)): QSqlQuery::exec: database not open -
main file is given below
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtCharts/QChartView>
#include <QtCharts/QSplineSeries>
#include <devicedata.h>
#include <QThread>
#include <devicethread.h>
#include <themewidget.h>
#include <QtCore/QtPlugin>
//DeviceData obj_DeviceData;
QT_CHARTS_USE_NAMESPACE
//Q_IMPORT_PLUGIN(qsqlite)int main(int argc, char *argv[])
{
QApplication a(argc, argv);QMainWindow window; ThemeWidget *widget = new ThemeWidget(); window.setCentralWidget(widget); window.resize(900, 600); window.show(); DeviceData obj_DeviceData; //access database and open connection obj_DeviceData.syncDevice(true); //start receiving data over bluetooth and //save into sqlite database return a.exec();
}
-
Hi,
Please share the code where you open your database connection.
-
@SGaist
DeviceData::DeviceData()
{
m_bterminate=false;
m_db = QSqlDatabase::addDatabase("QSQLITE");m_db.setDatabaseName("/home/user/db_Health.db"); if (!m_db.open()) { qDebug() << "Error: connection with database fail"; } else { qDebug() << "Database: connection ok"; }
}
This constructor code is called from the main thread posted above
-
You are trying to open a database in a folder that doesn't exists on your Android device.
Use QStandardPaths to retrieve a properly usable folder.
-
@SGaist : this error is linker error. Does qt verify path before building the apk.
-
@SGaist
I used QStandardPaths
still the error is thereDeviceData::DeviceData(QObject *parent)
: QObject(parent), m_bluetoothSocket(0)
{try { m_bterminate=false; m_db = QSqlDatabase::addDatabase("QSQLITE"); //m_db.setDatabaseName("/home/user/db_Health.db"); QString basePath = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)[1]; m_db.setDatabaseName(basePath+"/db_Health.db"); if (!m_db.open()) { qDebug() << "Error: connection with database fail"; }
path is basePath "/storage/emulated/0/Android/data/org.qtproject.example.splinechart/files"
-
Rather than just a message, print the the actual error QSqlDatabase returns.
Then start your application with theQT_DEBUG_PLUGINS
environment variable set to 1.Last point, Qt for Android is a dynamic build so unless you built it yourself statically, there's no need to apply static plugin code.