Qt Android Manifest File Configuration

The Android Manifest is an XML file necessary for any Android app. It contains app configuration for different settings and features that the app use, as well as details on the app itself, such as, package name, app name, version, etc. Permissions and hardware features can also be set from the manifest.

Qt for Android maintains a version of AndroidManifest.xml with default configuration that include features, permissions and other configuration used by the build system which are needed for building and running Qt apps on Android.

Qt Project to Manifest Configuration

Qt defines some meta-data that is passed from the build systems and to androiddeployqt which populates the manifest with the correct values without explicitly setting these in the manifest file. Such meta-data is assigned a value in the form "-- %%INSERT_VALUE%% --", for example:

<manifest ...
    android:versionCode="-- %%INSERT_VERSION_CODE%% --"
    ...
</manifest>

This would be populated with the version code that is set in, for example, CMake.

Qt Default Configuration

Qt sets the following manifest configuration by default:

SectionOptionDescription
<manifest>packageSets the package name. Default: org.qtproject.example.app_name.
android:installLocationSets the app's installation location, whether internal or external storage. Default: auto.
android:versionCodeSets the internal version code. Populated from ANDROID_VERSION_CODE (qmake) and QT_ANDROID_VERSION_CODE (CMake). Default: 1.
android:versionNameSets the public version name. Populated from ANDROID_VERSION_NAME (qmake) and QT_ANDROID_VERSION_NAME (CMake). Default: 1.0.
<supports-screens>Sets the screen sizes that the app supports, default values are anyDensity, largeScreens, normalScreens, and smallScreens.
<application>android:nameThe application class name. Default: org.qtproject.qt.android.bindings.QtApplication.
android:labelThe application name label. Default: the Qt project's target name.
android:extractNativeLibsExtracts the native C++ libraries on installation. Default: true.
android:hardwareAcceleratedSets hardware accelaration preference. Default: true.
android:requestLegacyExternalStorageWhether to use Android scoped storage. Default true.
<activity>android:nameThe activity class name. Default: org.qtproject.qt.android.bindings.QtActivity.
android:labelThe activity name label. Default: the Qt project's target name.
android:configChangesLists configuration changes that the activity handles. Default: orientation, uiMode, screenLayout, screenSize, smallestScreenSize, layoutDirection, locale, fontScale, keyboard, keyboardHidden, navigation, mcc, mnc, density.
android:launchModeThe method used to launch the activity. Default: singleTop.
android:screenOrientationThe orientation of the activity's display on the device. Default: unspecified.
<intent-filter>Specifies the types of intents that the activity can respond to. Default:
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

Qt Specific Meta-data

In addition to the default manifest configuration that Qt sets, Qt defines some meta-data that is valid for Qt apps only. Such meta-data is usually under the <activity> section in the form:

<meta-data
    android:name="meta-data-name"
    android:value="meta-data-value" />

The following is a list of such meta-data defined by Qt:

meta-data nameDescription
android.app.lib_nameThe filename of the native C++ library that is used by the activity.

Note: This attribute is mandatory and shouldn't be removed. Default: the Qt project's target name.

android.app.extract_android_styleThe method used to extract the native Android Style information. For more information, see Style Extraction. Default: minimal.
android.app.background_runningSets whether the app keeps running tasks in the background. Setting this to true is the equivalent of setting the environment variable QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED to 0. Default: false.

Warning: Setting this to true may cause unexpected crash if the application tries to draw after QGuiApplication::applicationStateChanged() signal is sent with a Qt::ApplicationSuspended state.

android.app.argumentsSets a list of arguments to pass to the app "arg1 arg2". Populated from ANDROID_APPLICATION_ARGUMENTS (qmake) and QT_ANDROID_APPLICATION_ARGUMENTS (CMake). Default: not set.
android.app.splash_screen_drawable_portraitSets a drawable for a splash screen specific to portrait mode. For example: android:resource="@drawable/splash_portrait". Default: not set.
android.app.splash_screen_drawable_landscapeSets a drawable for a splash screen specific to landscape mode. For example: android:resource="@drawable/splash_landscape". Default: not set.
android.app.splash_screen_drawableSets a drawable for a splash screen at the start of the app.

Note: Orientation specific splash screens are checked first, if not set, this is used instead. For example: android:resource="@drawable/splash". Default: not set.

android.app.splash_screen_stickySets whether the splash screen stays visible until explicitly hidden by the app. For more information, see QAndroidApplication::hideSplashScreen(). Default: false.
android.app.system_libs_prefixSpecifies a custom system library path to use for library loading lookup. This is necessary when running as a system app. Default: /system/lib/.

Meta-data in Services

Some meta-data attributes can also be used in Services. The main ones are:

Qt Permissions and Features

Different Qt modules might require some Android permissions or features to function properly, for example, Camera permission in QtMultimedia. The androiddeployqt tool takes care of including such requirements into the Android manifest during the build. Qt defines the following lines into the manifest, which they get replaced by the actual values:

<manifest ...
    <!-- %%INSERT_PERMISSIONS -->
    <!-- %%INSERT_FEATURES -->
    ...
</manifest>

Note: If those lines are removed from the project manifest, Qt won't be able to include the correct permissions. So some functionalities might not work properly.

Style Extraction

Qt uses different methods to determine how Qt Widgets and Qt Quick Controls should be styled:

  • default or full: when using Qt Widgets or Qt Quick Controls 1.

    Note: This method uses some Android non-SDK interfaces, that are being restricted and removed by Google starting from Android 9.0 (API 28). For that reason, this is not recommended for Android 9.0 or greater.

  • minimal: when using Qt Quick Controls 2 and no Qt Widgets or Qt Quick Controls 1. This is faster than using the default or full options.
  • none: no style extraction.

Qt Manifest before 6.2 Release

Versions of Qt earlier than 6.2 used to have an additional set of meta-data defined by Qt. These attributes used to manage dependencies and some were used by the discontinued Ministro service. With Qt 6.2, they should be removed. Here is a list of these attributes:

  • android.app.qt_sources_resource_id
  • android.app.repository
  • android.app.bundled_libs_resource_id
  • android.app.bundle_local_qt_libs
  • android.app.use_local_qt_libs
  • android.app.libs_prefix
  • android.app.load_local_libs_resource_id
  • android.app.load_local_jars
  • android.app.static_init_classes
  • android.app.qt_libs_resource_id
  • android.app.ministro_not_found_msg
  • android.app.ministro_needed_msg
  • android.app.fatal_error_msg

For more information on the Android Manifest, see Android App Manifest.

© 2021 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.