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

Building Android CMake Projects



  • Hi

    I'm working on a CMake based Android project and have some questions regarding the build process.

    1. I would like to know the relation between a native build and the Android SDK (not NDK). The SDK is selected in the "Build APK" step, not in the cmake configure/build steps. So the native libraries do not depend on them, and I thought the APK was just to call the native main function, which would make a higher SDK level useless.

    2. I would like to know how to build a CMake based project using the command line (e.g. for CI/CD). The CMake build step is easy, as I can just copy the Variables from QtCreator and call CMake directly. But how do I build the APK? How can I make an AAB from multiple builds? And if the SDK level is important, can I make an AAB for the same ABI but with different SDK levels?


  • Moderators

    @Larvae said in Building Android CMake Projects:

    Hi

    I'm working on a CMake based Android project and have some questions regarding the build process.

    1. I would like to know the relation between a native build and the Android SDK (not NDK). The SDK is selected in the "Build APK" step, not in the cmake configure/build steps. So the native libraries do not depend on them, and I thought the APK was just to call the native main function, which would make a higher SDK level useless.

    SDK is required to build an .apk package and to properly run the Qt wrappers (QtActivity, gradle and all the other Java code).

    1. I would like to know how to build a CMake based project using the command line (e.g. for CI/CD). The CMake build step is easy, as I can just copy the Variables from QtCreator and call CMake directly. But how do I build the APK? How can I make an AAB from multiple builds? And if the SDK level is important, can I make an AAB for the same ABI but with different SDK levels?
    1. Build with cmake.
    2. Run androiddeployqt.
    3. Take the .apk from build dir.

    Possibly, since Qt 5.14, it's enough to run make apk to automatically run androiddeployqt (as in qmake), but I don't know.

    If you want to bundle multiple APKs - the process is the same, you just need to set more architectures when building with cmake. You can do it by setting ANDROID_BUILD_ABI_arm64-v8a, ANDROID_BUILD_ABI_armeabi-v7a, ANDROID_BUILD_ABI_x86 and ANDROID_BUILD_ABI_x86_64 options in cmake.


Log in to reply