Nominate our 2022 Qt Champions!

[solved] how to add .so library to android apk

  • Hello,

    I am new to Qt and struggling to be able to add postgresql library file to the android project. I am using Qt on 64 bit windows system and developing for android.
    I tried to add by adding this line to .pro file

    @LIBS += -L "e:\sqlib"

    The app is built but when i open apk file with winRar, no is found in the lib folder. I also added this code to my cpp file:

    @QLibrary library("");

    if (!library.load())

    this code returns "no driver found message".

    Previously I tried without adding any extra library but it wasn't working. This is actually what I'm trying to accomplish:

    @QSqlDatabase db= QSqlDatabase::addDatabase("QPSQL");

        bool ok =;
                QMessageBox::information(this,"Connection","Connection Failed!");
            { . . . .}

    can anyone please help me?

    EDIT: I forgot to mention that I did a lot of google search before posting question but at last decided to ask.

  • "LIBS+=" is for linking. Plugins don't need to be linked so you can remove that line.

    To add the required so files for postgresql plugin add the following lines to your pro file.

  • [solution]

    [quote author="antreimer" date="1424556611"]I now statically linked the plugin so nothing should be needed to do other then to copy it into the sqldrivers plugin folder[/quote]

    As prescribed by antreimer I downloaded the file from quoted link and copied to path/to/Qt/android_armv7/plugins/sqldrivers. Nothing else is required. The library is automatically added and no modification to the .pro file is required

Log in to reply