Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android build failing at APK step

Android build failing at APK step

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 134 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote last edited by
    #1

    Hi all -

    I've been wrestling with this issue for a few days, and I think I'm going around in circles.

    I'm trying to build my app for Android. The build step seems to execute OK, but when it comes to building the APK, I get an error:

    Cannot find android sources in C:/QtProjects/NgaIcdFw/appNgaIcdFw/android/src/main;C:/QtProjects/NgaIcdFw/appNgaIcdFw/android09:07:21: The process "C:\Qt\6.8.3\mingw_64\bin\androiddeployqt.exe" exited with code 11.
    

    During cmake, android-appNgaIcdFw-deployment-settings.json is created in my build directory, and it contains the incorrect (and invalid path):

       "android-package-source-directory": "C:/QtProjects/NgaIcdFw/appNgaIcdFw/android/src/main;C:/QtProjects/NgaIcdFw/appNgaIcdFw/android",
    

    I've tried many suggestions from ChatGPT to stop this, mostly centering around my creating my own .json file and trying to force cmake to use it with lines like this:

        # Override deployment settings used by Qt Creator
        set(QT_ANDROID_DEPLOYMENT_SETTINGS_FILE
            "${CMAKE_CURRENT_SOURCE_DIR}/appNgaIcdFw/android-deployment-settings.json"
            CACHE FILEPATH "Use maintained deployment settings file"
        )
    

    But nothing I do prevents that file from being produced, and with a bad path.

    Any idea where that bad path is coming from, and what I can do about it? Thanks...

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote last edited by JoeCFD
      #2

      I do not use chatgpt that much as before. If you try different chatbots(grok, deepseek), you may get different tips or solutions. Grok is supposed to be better than chatgpt as it was claimed that grok uses the most GPUs. Deepseek often gives me good code as well.

      1 Reply Last reply
      1
      • cristian-adamC Online
        cristian-adamC Online
        cristian-adam
        wrote last edited by
        #3

        The code that creates the android-<app>-deployment-settings.json file is part of Qt6AndroidMacros.cmake found at https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/Qt6AndroidMacros.cmake?h=6.8.3#n217

           # package source dir
            _qt_internal_add_android_deployment_property(file_contents "android-package-source-directory"
                ${target} "_qt_android_native_package_source_dir")
        

        Which at https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/Qt6AndroidMacros.cmake?h=6.8.3#n1018 we found out that it refers to the target property QT_ANDROID_PACKAGE_SOURCE_DIR.

        QT_ANDROID_PACKAGE_SOURCE_DIR is documented at https://doc.qt.io/qt-6/cmake-target-property-qt-android-package-source-dir.html

        If I look at the Dice Demo at https://code.qt.io/cgit/qt/qtdoc.git/tree/examples/demos/dice/CMakeLists.txt?h=6.8 I can see:

        if(ANDROID)
            set_target_properties(${appname} PROPERTIES
                QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
                QT_ANDROID_PACKAGE_NAME "io.qt.dice"
                QT_ANDROID_TARGET_SDK_VERSION 34
                QT_ANDROID_VERSION_CODE 10
                QT_ANDROID_VERSION_NAME "1.0"
            )
        
            qt_import_plugins(${appname}
                INCLUDE_BY_TYPE imageformats Qt::QSvgPlugin Qt::QJpegPlugin
                EXCLUDE_BY_TYPE qmltooling
                EXCLUDE_BY_TYPE iconengines
                EXCLUDE_BY_TYPE networkinformation
                EXCLUDE_BY_TYPE tls
                EXCLUDE_BY_TYPE platforminputcontexts
            )
        endif()
        

        Please do have a look at your CMakeLists.txt code which probably sets something wrong or not at all.

        mzimmersM 1 Reply Last reply
        1
        • cristian-adamC cristian-adam

          The code that creates the android-<app>-deployment-settings.json file is part of Qt6AndroidMacros.cmake found at https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/Qt6AndroidMacros.cmake?h=6.8.3#n217

             # package source dir
              _qt_internal_add_android_deployment_property(file_contents "android-package-source-directory"
                  ${target} "_qt_android_native_package_source_dir")
          

          Which at https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/Qt6AndroidMacros.cmake?h=6.8.3#n1018 we found out that it refers to the target property QT_ANDROID_PACKAGE_SOURCE_DIR.

          QT_ANDROID_PACKAGE_SOURCE_DIR is documented at https://doc.qt.io/qt-6/cmake-target-property-qt-android-package-source-dir.html

          If I look at the Dice Demo at https://code.qt.io/cgit/qt/qtdoc.git/tree/examples/demos/dice/CMakeLists.txt?h=6.8 I can see:

          if(ANDROID)
              set_target_properties(${appname} PROPERTIES
                  QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
                  QT_ANDROID_PACKAGE_NAME "io.qt.dice"
                  QT_ANDROID_TARGET_SDK_VERSION 34
                  QT_ANDROID_VERSION_CODE 10
                  QT_ANDROID_VERSION_NAME "1.0"
              )
          
              qt_import_plugins(${appname}
                  INCLUDE_BY_TYPE imageformats Qt::QSvgPlugin Qt::QJpegPlugin
                  EXCLUDE_BY_TYPE qmltooling
                  EXCLUDE_BY_TYPE iconengines
                  EXCLUDE_BY_TYPE networkinformation
                  EXCLUDE_BY_TYPE tls
                  EXCLUDE_BY_TYPE platforminputcontexts
              )
          endif()
          

          Please do have a look at your CMakeLists.txt code which probably sets something wrong or not at all.

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote last edited by
          #4

          @cristian-adam I ended up adding this line to my cmake file:

          set_property(TARGET appNgaIcdFw PROPERTY QT_ANDROID_DEPLOYMENT_SETTINGS_FILE "${CMAKE_CURRENT_BINARY_DIR}/android-appNgaIcdFw-deployment-settings.json")
          

          Seems to have resolved this issue.

          1 Reply Last reply
          1
          • mzimmersM mzimmers has marked this topic as solved

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved