Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93372

Cannot generate Android APK with androiddeployqt from command line

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.15.2
    • None
    • macOS 11.3, Android NDK 21e
    • Android, macOS
    • 2023wk26FOQtforAndroid

    Description

      I am building an Android application with cmake. Cmake is run with the following parameters:

      ANDROID_ABI=armeabi-v7a
      NDK_ROOT=$HOME/android-ndk-r21e
      ANDROID_PLATFORM=28
      SDK_ROOT=$HOME/Library/Android/sdk
      ANDROID_BUILD_TOOLS_REV=28.0.3
      cmake .. -DCMAKE_BUILD_TYPE=Release \
                           -DCMAKE_PREFIX_PATH=$HOME/Qt/$QT_VER/android \
                           -DCMAKE_ANDROID_NDK=$NDK_ROOT \
                           -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake \
                           -DANDROID_ABI=$ANDROID_ABI \
                           -DANDROID_PLATFORM=$ANDROID_PLATFORM \
                           -DANDROID_SDK=$SDK_ROOT \
                           -DANDROID_BUILD_TOOLS_REV=$ANDROID_BUILD_TOOLS_REV \
                           -DSTORE_FILENAME=$STORE_FILENAME \
                           -DSTORE_USERNAME=$STORE_USERNAME \
                           -DSTORE_PASSWORD=$STORE_PASSWORD
      

      In CMakeLists file I have added a custom target to run androiddeployqt

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

      Generating the APK with the above command gives an error about zipalign not found. I can solve this error by changing manually Qt5AndroidSupport.cmake in Qt 5 installation such that the following line is added when android_deployment_settings.json.in file is created

      "sdkBuildToolsRevision": "@ANDROID_BUILD_TOOLS_REV@"
      

      With this change the APK is generated and signed but cannot be installed on the device. Also, the AndroidManifest.xml file does not contain the correct permissions and I don't find a way for providing a custom manifest file.

      When instead of androiddeployqt I am using

      cmake --build . --target apk
      

      the debug APK is generated and can be installed and run on the device. The manifest file is the same as for androiddeployqt

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            assam Assam Boudjelthia
            cristeab Bogdan Cristea
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes