Multiple QT Applications (activities) in one APK



  • I am wondering if it is somehow possible to have multiple QT (QML) applications (activities) in one APK?

    First let me explain a little about how my application is partitioned on Windows where everything now is working as it should.

    • I have one service that is always running in the background and doing the job.
    • I have one management application used to configure everything. This app uses QT.
    • I have one user application that is unique for each user and displays notifications and information relevant to this user. This app uses QT and has a tray icon.

    On Andorid I would like to do something similar. I therfore would like to have all three parts in on APK. I have the management application (Android Activity via QtActivity) and service (Android Service via JNI) working but I have not been able to add the user application. If I add the shared library that contains the user application in the APK, without even adding it to the manifest, the Managemen application does not work anymore. I am guessing there is a problem with multiple symbols in the libraries.
    So I am wondering if there is any way around it?

    Btw, I build everything with CMake (bulds all c++ and generates grandle build files for the APK via androiddeployqt).

    Perhaps my only option is to build the GUI for the user application in Java, if I need it to have only one APK. This gui is not that extensive so perhaps it is the easiest way.



  • I now have it working somewhat. I had the libraries for my service and the user app specified as "android-extra-libs" in the file qt-deploy.json. This added the libraries to the package wich I wanted but it also loaded the libraries when starting the activity. So instead a made sure the libraries are copied into the libs folder after androiddeployqt has run but before the gradle build.
    So my my cmake project now first builds all my C++ code, runs androiddeployqt, copies my own shared libraries to libs and then start the gradle build, so that seems quite nice! I put both activities in their own process and thought that I had solved it.

    But......
    It is still not really working. I can launch one application at a time but if I launch one application and then put it in the background and launch the other application, then the first application is displayed. I think it is because the QtActivity code calls static method QtApplication.invokeDelegate and since it is static it will send it to the wrong place.
    So is there a way around this? I think I maybe can solve it if I start to change the QtActivity and QtApplication classes but I don't really like this.



  • Now It works, I had to have different taskAffinity on the two activities. So it had nothing to do with QT.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Glad you found a solution !

    Your project setup looks like something more users might encounter or like to do, would mind sharing how you did that ? e.g. through a wiki article



  • So much to do and so little time....
    For CMake build for android I used the following: https://github.com/LaurentGomila/qt-android-cmake.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.