QT_ANDROID_PACKAGE_NAME

该应用的包名。

该属性自 Qt 6.8 起引入。

注意: 仅当目标平台为 Android 时,才会使用此 属性。

指定应用的包名。这通常是应用的一个由点分隔的唯一名称,用于在设备上或 Google Play 商店中识别该应用。例如,“org.qtproject.gallery”。

set_target_properties(${target} PROPERTIES
    QT_ANDROID_PACKAGE_NAME "org.qtproject.gallery"
)

该属性设置的包名将作为namespace 属性传递给build.gradle 文件,而非AndroidManifest.xml ,因为后者自Android Gradle Plugin 7.4起已弃用。

包名会将某些单词或字符视为非法,若遇到此类名称,构建过程将对其进行清理。下划线(_ )会替换非法字符,或附加在非法单词之后。

  • 允许的字符:字母数字、下划线或点 [a-zA-Z0-9_.].
  • 非法词汇:abstract、continue、for、new、switch、assert、default、if、package、synchronized、boolean、do、goto、private、this、break、double、implements、protected、throw、byte、else、import、public、throws、 case、enum、instanceof、return、transient、catch、extends、int、short、try、char、final、interface、static、void、class、finally、long、strictfp、volatile、const、float、native、super、while。

Qt for Android 应用的默认包名是org.qtproject.example.<target_name> 。

注意: 在build.gradle 中手动设置 包名(通过namespace 属性)优先于AndroidManifest.xml (通过package 属性),而后者也优先于该属性。

有关更多信息,请参阅 Android的“配置应用模块”。

另请参阅 qt_android_generate_deployment_settings()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.