Android build failing at APK step
-
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...
-
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.
-
The code that creates the
android-<app>-deployment-settings.json
file is part ofQt6AndroidMacros.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.htmlIf 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. -
The code that creates the
android-<app>-deployment-settings.json
file is part ofQt6AndroidMacros.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.htmlIf 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.@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.
-
M mzimmers has marked this topic as solved