QMYSQL working on Windows and Mac but not Android

  • Hi, I have the QMYSQL driver working fine for Windows and Mac, but as soon as I deploy to the same app to Android from windows I get this error:

    W         : (null):0 ((null)): QSqlDatabase: QMYSQL driver not loaded
    W         : (null):0 ((null)): QSqlDatabase: available drivers: QSQLITE
    W         : (null):0 ((null)): QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins

    contents of my qtbase/plugins/sqldrivers :


    This only happened after a recent fresh install of windows everything was fine before. Thanks for any help.

    Windows 10 pro
    Qt 5.9
    android armv7

  • Moderators

    you can use qputenv("QT_DEBUG_PLUGINS", "1") before creating a QApplication instance and check the output. It might give some hints what is failing.

    IIRC the mysql plugin also links against mysql lib. So did you also deploy this one?

  • @raven-worx Hi, thanks for quick response I will use qputenv("QT_DEBUG_PLUGINS", "1") and see what i get. Tbh not sure what you mean here: "IIRC the mysql plugin also links against mysql lib. So did you also deploy this one?"

  • Lifetime Qt Champion

    @LeeH You need libmysql.so on your device as well, that is what @raven-worx means.

  • @jsulm Hi, I am new to this area of Qt lol... so I did a search for 'libmysql.so' but only have 'libmysql.dll' and 'libmysql.lib' on my computer. Is this missing file the reason??? I do not recall needing it before... i dunno

  • Lifetime Qt Champion

    @LeeH You always need it - it is the actual interface to MySQL and is used by Qt MySQL plug-in.
    'libmysql.dll' and 'libmysql.lib' - this is for Windows, you need one for Android.

  • @jsulm ah ok, so could you please tell me how to get it? What I don't understand is why it all worked on my previous installation, and why/where things have gone wrong here...

  • Lifetime Qt Champion

    @LeeH The correct name is actually libmysqlclient.so, I don't know why it worked for you before.
    Maybe this can help: https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android

  • @jsulm thanks for that post but I had seen that page way back when I first had problems building the mysql driver on windows. It didn't make sense to me then, and it doesn't now tbh, but I did get it to work perfectly without that. Maybe I should reinstall the android sdk's? It seems like its just a deployment to android issue, but I am open to any new suggestions... cheers

  • @raven-worx Hi, I put:

    qDebug() << qputenv("QT_DEBUG_PLUGINS", "1"); 
    QApplication app(argc, argv);

    and in the android log it return 'true'

    D         : ..\test\main.cpp:31 (int main(int, char**)): true

    Is this what you meant? Is it doing what it's supposed to? Did I make a mistake?

  • Moderators

    @LeeH said in QMYSQL working on Windows and Mac but not Android:

    Is this what you meant?

    no, not what this command returns.
    With this env variable set Qt should print some debug info of the plugin loading process.

  • @raven-worx ok - but there is a lot of information here, and I don't know what I'm looking for, I can't see anything about debug for plugins.

  • @raven-worx Hi, I think I've managed to find the additional info that 'qputenv("QT_DEBUG_PLUGINS", "1");' provides. I hope it's what you meant but here it is:

    W libtest.so: (null):0 ((null)): Found metadata in lib /data/data/org.qtproject.example.test/qt-reserved-files/plugins/sqldrivers/libqsqlite.so, metadata=
    W libtest.so: {
    W libtest.so:     "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    W libtest.so:     "MetaData": {
    W libtest.so:         "Keys": [
    W libtest.so:             "QSQLITE"
    W libtest.so:         ]
    W libtest.so:     },
    W libtest.so:     "className": "QSQLiteDriverPlugin",
    W libtest.so:     "debug": false,
    W libtest.so:     "version": 329985
    W libtest.so: }


  • Lifetime Qt Champion


    It confirms that only the SQLite plugin is available for android.

    IIRC, you can now find more information about how to use QtWidget and custom plugins altogether.

  • @SGaist Hi, thanks for your reply. I am really stuck and confused here because as I mentioned in earlier post I did not need to build the android driver seperately before, I just installed mysql software from their site and loaded the windows mysql driver and mysql worked from windows and android perfectly, Might sound silly but I've tried uninstalling and reinstalling mysql community software in a hope to try to replicate what I did before. but no luck. If I do need to build it manually this time, then the info here: https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android (I assume I need option 3) but is even more confusing at this moment because option 3 appears to be incomplete. What can I do? Thanks.

  • Lifetime Qt Champion

    Then please, show that earlier version that worked. Oracle doesn't provide any official driver for Android otherwise the Qt SDK would be offered with that plugin already built.

    Option 3 is not incomplete, it's not there as it's written it's a stub.

  • @SGaist Hi again, sorry not earlier version of mysql server community software as that was and is 5.7. I meant Qt version 5.8 is when everything just worked, so Ive been back and forth between Qt 5.8 and 5.9.1. However when I have returned to Qt 5.8 android dosen't build at all, there are no sdk's available in my android build apk area even though they are installed. I also have sdk tools 25.2.5. But in Qt 5.9.1 These problems don't exist and android builds fine, but complains about the mysql driver... I'm loosing my mind!

  • I think I know where I messed up. I'm not sure, but I need to sort it out when I get more time... Thanks to you all for your help so far. Hopefully I should get this sorted.

  • I thought I did something wrong but after correcting that it didn't make a difference... Anyway I have accepted that how it worked before is gone , so I need to build it myself. I have now got MSYS installed and that appears to work:

    MSYS 1.0.11
    MSYS DTK 1.0
    MSYS Core 1.0.11

    I am now trying to work through option 2 https://wiki.qt.io/Build_Qt_5_MySQL_Plugin_for_Android. Before running the script, I edit these lines:


    export ANDROID_NDK_ROOT="/d/SDKs/Android/ndk-bundle"
    export QT_ROOT="/d/SDKs/Qt/5.7"
    BR="$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi- 4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-"


    export ANDROID_NDK_ROOT="/c/android-ndk-r15b"
    export QT_ROOT="/c/Qt/5.9"

    I leave everything else as it is then run the script. At the end I get:

    sh: !": event not found

    Then check in the output directory I set for the .so file and file is not there. I have never used MSYS before, I'm just trying to follow steps on wiki page option 2... thanks

  • Lifetime Qt Champion

    Like I already wrote, no Qt release was provided with MySQL driver for Android since there's no official client library for that platform.

    As for the error you got, it seems related to the sh interpreter, you should look up for that.

  • @SGaist Thanks for your help.

Log in to reply