Qt for Android provides everything you need to develop, build, and package Android apps. This guide shows you how to configure, build, and publish your app to Google Play Console.
Configure your Android app settings using CMake APIs or by editing the manifest directly. Android apps require various settings in
AndroidManifest.xml
and Gradle build files. Qt 6 provides convenient CMake APIs to manage these from your project.
Define your app's package name, version, and Android SDK requirements:
set_target_properties(${appname} PROPERTIES
QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android"
QT_ANDROID_PACKAGE_NAME "io.qt.calqlatr"
QT_ANDROID_APP_NAME "Calqlatr"
QT_ANDROID_TARGET_SDK_VERSION 35
QT_ANDROID_MIN_SDK_VERSION 28
QT_ANDROID_VERSION_NAME "1.0"
QT_ANDROID_VERSION_CODE 10
)
注意:
检查
current Google Play target SDK version requirement
并设置
QT_ANDROID_TARGET_SDK_VERSION
accordingly. You can target higher versions than the minimum requirement.
Set your app icon and create the icon files in the correct directories:
set_target_properties(${appname} PROPERTIES
QT_ANDROID_APP_ICON "@drawable/ic_launcher"
)
Place your icon files in:
<QT_ANDROID_PACKAGE_SOURCE_DIR>/res/drawable-<dpi>
You can create icon files using:
Reduce your app size by specifying which plugins to include. The androiddeployqt tool may include plugins your app doesn't need at runtime:
qt_import_plugins(${appname}
INCLUDE_BY_TYPE imageformats Qt::QSvgPlugin Qt::QJpegPlugin
EXCLUDE_BY_TYPE iconengines networkinformation tls platforminputcontexts qmltooling
)
注意: The qt_import_plugins() function only includes plugins from your target's linked dependencies.
Build your app for release and prepare it for Google Play Console submission.
Google Play requires release builds. Debug information can be included as separate files and is encouraged for better crash reporting:
qt-cmake -DCMAKE_BUILD_TYPE=Release
Ensure debuggable is set to
false
in your manifest or Gradle configuration.
Build your app for multiple device architectures to maximize compatibility:
QT_ANDROID_BUILD_ALL_ABIS
to
ON
qt-cmake -DQT_ANDROID_BUILD_ALL_ABIS:BOOL=ON ...
Google Play Console requires signed app releases. Google recommends using Google Play managed signing with two keys:
See Signing Android Packages for detailed instructions.
keytool -genkey -keyalg RSA -keystore upload-key.keystore \
-alias play_apps \
-storepass <password> -keypass <key-password> \
-dname "CN=<n>, OU=<unit>, O=<organisation>, L=<city>, ST=<state>, C=<country>"
Enable signing:
qt-cmake -DQT_ANDROID_SIGN_APK:BOOL=ON -DQT_ANDROID_SIGN_AAB:BOOL=ON ...
Set the environment variables:
export QT_ANDROID_KEYSTORE_PATH=upload-key.keystore export QT_ANDROID_KEYSTORE_ALIAS=play_apps export QT_ANDROID_KEYSTORE_STORE_PASS=<password> export QT_ANDROID_KEYSTORE_KEY_PASS=<key-password>
Google Play Console now primarily accepts Android App Bundles (AAB) instead of APKs. AAB packages allow Google Play to optimize app delivery for each device.
Generate an AAB:
cd build cmake --build . --target aab
For a specific target:
cmake --build . --target appname_make_aab
Your AAB file is saved to:
/<build-path>/android-build-appname/build/outputs/bundle/release/
After building and signing your app, publish it to Google Play Console for distribution.
Before uploading:
To create an account if you don't have one, see Google's Play Console setup guide .
For Qt versions that don't support multi-ABI builds (such as qmake projects), build each architecture separately with different version codes:
ANDROID_VERSION_CODE = <unique_version>
Consider using a versioning scheme like
<Platform><ABI><AppVersion>
:
Example: Release 1.0 for arm64-v8a uses version code
16410
.
See Google's app versioning 文档编制了解细节。
另请参阅 在 Android 部署应用程序 .