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

Cross-compile application for Android and generate apk from command line



  • Hi
    I am trying to cross-compile an apk for Android on macOS using Qt5.15.2 with cmake.
    While Android NDK has support for cross-compiling with cmake, androiddeployqt is not able to generate correctly the apk file. The custom target used to generate the apk is shown below:

    add_custom_target(pack COMMAND ${androiddeployqt_ROOT_PATH}/bin/androiddeployqt
               --input android_deployment_settings.json
               --output ${CMAKE_BINARY_DIR}/android-build
               --android-platform android-21
               --gradle
               --release
               --sign ${STORE_FILENAME} ${STORE_USERNAME}
               --storepass ${STORE_PASSWORD})
    

    But it exists with error because it cannot find zipalign.

    I was able to generate the apk, after changing this file
    ~/Qt/5.15.2/android/lib/cmake/Qt5Core/Qt5AndroidSupport.cmake
    such that sdkBuildToolsRevision is defined as
    "sdkBuildToolsRevision": "21.1.1",
    In this way zipalign is found by androiddeployqt.

    However, I still need to configure AndroidManifest.xml.
    So my question is how can I specify a custom AndroidManifest.xml file to be used by androiddeployqt ? Previously, with qmake, there was a way to specify a folder where AndroidManifest.xml could be put, ANDROID_PACKAGE_SOURCE_DIR, but I don't know how to do the same in cmake.

    thank you
    Bogdan



  • I have created a bug report here: https://bugreports.qt.io/browse/QTBUG-93372


Log in to reply