Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Dynamic libs on Android with Qt5.14.2



  • My application is using dynamic link libraries on Android. The libraries are compiled in a separate project and added in the .pro file with a ANDROID_EXTRA_LIBS statement. Up to Qt5.12.7 the libraries were added into the apk file. Now with Qt5.14.2 this is no longer the case. The application is crashing when started on Android.

    Is there a different way to add the dynamic link libraries under Android for Qt5.14.2 ?


  • Moderators

    ANDROID_EXTRA_LIBS should still work.

    Some things which may help:

    • regenerate Android templates in Qt Creator (Qt 5.14 updates the templates significantly, old ones do not work anymore!)
    • search your whole source code for ANDROID_EXTRA_LIBS. I once had a case where Qt Creator automatically inserted ANDROID_EXTRA_LIBS= (variable was emptied!) into my .pro file. So I thought I had everything fine, libs added, but actually the .pro file was removing the libs I set earlier :-)
    • if all else fails, you can try adding the extra libs through Qt Creator's manifest editor form (double click on your AndroidManifest.xml in QtC)


  • @sierdzio

    Sorry took me a while toget back to the issue.

    On Build Android APK the libraries are shown under "Additional libraries". However, still no success.

    @sierdzio said in Dynamic libs on Android with Qt5.14.2:

    • if all else fails, you can try adding the extra libs through Qt Creator's manifest editor form (double click on your AndroidManifest.xml in QtC)

    How do you mean that? The mask does not allow to add libraries. At least it is not obvious to me.



  • The question is my previous post is still unclear.

    However, I made some progress to get ANDROID_EXTRA_LIBS to work.
    Nevertheless , I cannot believe what I see.

    When setting the variable directly with the accurate absolute path, it does not work.
    When using $$PWD which will result into the same absolute path it does work.

    When assembling the variable using some decisions, it does not work.
    When setting the variable within the same decision, it does not work. Even when using the exact statement as when it works outside of decisions.

    No logic at the moment.


  • Moderators

    After fighting with libs again in a new project, I've found another working, although quirky, solution:

    Use the android/libs dir to store the built libs. These are all automatically copied to the APK and there is no need to adjust any paths in the .pro or cmake files. https://doc.qt.io/qt-5/deployment-android.html#libraries



  • @sierdzio

    Thanks for reply.

    Certainly I have a solution. However, the situation is not really satisfactory. I was trying to get the project recompilable through qmake for different Qt versions. Apparently not possible at least with qmake.

    I am wondering if it is easier with using cmake?


  • Moderators

    Trick with android/libs should work for older Qt versions, too, and it works the same on qmake and cmake. If all else fails, you could have different .pri per Qt version... It's a nuisance for sure but my hope is that for Qt 5.14+ it will stay as it is for long.