Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
android-manifest-file-configuration.qdoc
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page android-manifest-file-configuration.html
6\title Qt Android Manifest File Configuration
7\ingroup androidplatform
8\brief Provides details on the AndroidManifest.xml configuration.
9\previouspage android-openssl-support.html
10\nextpage android-services.html
11
12The Android Manifest is an XML file necessary for any Android app. It contains
13app configuration for different settings and features that the app use, as well
14as details on the app itself, such as, package name, app name, version, etc.
15Permissions and hardware features can also be set from the manifest.
16
17Qt for Android maintains a version of \c {AndroidManifest.xml} with default
18configuration that include features, permissions and other configuration
19used by the build system which are needed for building and running Qt apps
20on Android.
21
22\section1 Qt Project to Manifest Configuration
23
24Qt defines some \l {Android: App Manifest <meta-data>}{meta-data} that is passed
25from the build systems and to \l {Deploying an Application on Android}{androiddeployqt}
26which populates the manifest with the correct values without explicitly setting
27these in the manifest file. Such \l {Android: App Manifest <meta-data>}{meta-data}
28is assigned a value in the form \c {"-- %%INSERT_VALUE%% --"}, for example:
29
30\badcode
31<manifest ...
32 android:versionCode="-- %%INSERT_VERSION_CODE%% --"
33 ...
34</manifest>
35\endcode
36
37This would be populated with the version code that is set in, for example,
38\c CMake.
39
40\section1 Qt Default Configuration
41
42Qt sets the following manifest configuration by default:
43
44\table
45\header
46 \li Section
47 \li Option
48 \li Description
49\row
50 \li {1, 5} \l {Android: App Manifest <manifest>}{<manifest>}
51 \li package
52 \li Sets the package name. The default value is \c {org.qtproject.example.app_name}.
53\row
54 \li \c {android:installLocation}
55 \li Sets the app's installation location, whether internal or external storage.
56 The default value is \c auto.
57\row
58 \li android:versionCode
59 \li Sets the internal version code. Populated from \c ANDROID_VERSION_CODE (qmake)
60 and \c QT_ANDROID_VERSION_CODE (CMake). The default value is \c 1.
61\row
62 \li android:versionName
63 \li Sets the public version name. Populated from \c ANDROID_VERSION_NAME (qmake)
64 and \c QT_ANDROID_VERSION_NAME (CMake). The default value is \c {1.0}.
65\row
66 \li \c {<supports-screens>}
67 \li Sets the screen sizes that the app supports,
68 default values are \c anyDensity, \c largeScreens,
69 \c normalScreens, and \c smallScreens.
70\row
71 \li {1, 7} \l {Android: App Manifest <application>}{<application>}
72 \li android:name
73 \li The application class name. Default value is
74 \c {org.qtproject.qt.android.bindings.QtApplication}.
75\row
76 \li android:label
77 \li The application name label. Default value is the Qt project's target name.
78\row
79 \li android:hardwareAccelerated
80 \li Sets hardware acceleration preference. The default value is \c true.
81\row
82 \li android:requestLegacyExternalStorage
83 \li Whether to use Android scoped storage. The default value is \c true.
84\row
85 \li android:allowNativeHeapPointerTagging
86 \li Whether or not the app has the Heap pointer tagging feature enabled.
87 This has to be set to \c false when targeting Arm64 hardware with Android 11+
88 because it can break QML's NaN-tagging scheme.
89 For more information, see \l {Android: Tagged Pointers}{Tagged Pointers}.
90 The default value is \c false.
91\row
92 \li android:allowBackup
93 \li Whether to allow the application to participate in the backup and restore
94 infrastructure. If this is set to \c false, no backup or restore of the
95 application will ever be performed. The default value is \c true.
96\row
97 \li android:fullBackupOnly
98 \li Whether or not to use Auto Backup on devices where it is available.
99 The default value is \c false.
100\row
101 \li {1, 7} \l {Android: App Manifest <activity>}{<activity>}
102 \li android:name
103 \li The activity class name. The default value is \c {org.qtproject.qt.android.bindings.QtActivity}.
104\row
105 \li android:label
106 \li The activity name label. Default value is the Qt project's target name.
107\row
108 \li android:configChanges
109 \li Lists configuration changes that the activity handles. Default value is
110 \c orientation, \c uiMode, \c screenLayout, \c screenSize,
111 \c smallestScreenSize, \c layoutDirection, \c locale, \c fontScale,
112 \c keyboard, \c keyboardHidden, \c navigation, \c mcc, \c mnc, \c density.
113\row
114 \li android:launchMode
115 \li The method used to launch the activity. The default value is \c singleTop.
116\row
117 \li android:screenOrientation
118 \li The orientation of the activity's display on the device. The default value is \c unspecified.
119\row
120 \li <intent-filter>
121 \li Specifies the types of intents that the activity can respond to. Default value is
122 \badcode
123 <action android:name="android.intent.action.MAIN"/>
124 <category android:name="android.intent.category.LAUNCHER"/>
125 \endcode
126\row
127 \li android:exported
128 \li Sets whether the activity can be launched by components of other applications.
129 The default value is \c true.
130\endtable
131
132\section1 Qt Specific Meta-data
133
134In addition to the default manifest configuration that Qt sets, Qt defines
135some meta-data that is valid for Qt apps only. Such meta-data is usually
136under the \c <activity> section in the form:
137
138\badcode
139<meta-data
140 android:name="meta-data-name"
141 android:value="meta-data-value" />
142\endcode
143
144The following is a list of such meta-data defined by Qt:
145
146\table
147\header
148 \li Meta-data Name
149 \li Description
150\row
151 \target android.app.lib_name
152 \li android.app.lib_name
153 \li The filename of the native C++ library that is used by the activity.
154 \note This attribute is mandatory and shouldn't be removed.
155 Default value is the Qt project's target name.
156\row
157 \li android.app.extract_android_style
158 \li The method used to extract the native Android Style information.
159 For more information, see \l {Style Extraction}.
160 The default value is \c minimal.
161\row
162 \target android.app.background_running
163 \li android.app.background_running
164 \li Sets whether the app keeps running tasks in the background.
165 Setting this to \c true is the equivalent of setting the environment
166 variable \c QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED to \c 0.
167 The default value is \c false.
168
169 \warning Setting this to \c true may cause unexpected crash if the
170 application tries to draw after \l {QGuiApplication::applicationStateChanged()}
171 signal is sent with a \l {Qt::ApplicationSuspended} state.
172\row
173 \target android.app.arguments
174 \li android.app.arguments
175 \li Sets a list of arguments to pass to the app \c {"arg1 arg2"}.
176 Populated from \c ANDROID_APPLICATION_ARGUMENTS (qmake) and
177 \c QT_ANDROID_APPLICATION_ARGUMENTS (CMake).
178 Default value is not set.
179\row
180 \li android.app.splash_screen_drawable_portrait
181 \li Sets a drawable for a splash screen specific to portrait mode.
182 For example: \c {android:resource="@drawable/splash_portrait"}.
183 Default value is not set.
184\row
185 \li android.app.splash_screen_drawable_landscape
186 \li Sets a drawable for a splash screen specific to landscape mode.
187 For example: \c {android:resource="@drawable/splash_landscape"}.
188 Default value is not set.
189\row
190 \li android.app.splash_screen_drawable
191 \li Sets a drawable for a splash screen at the start of the app.
192 \note Orientation specific splash screens are checked first,
193 if not set, this is used instead.
194 For example: \c {android:resource="@drawable/splash"}.
195 Default value is not set.
196\row
197 \li android.app.splash_screen_sticky
198 \li Sets whether the splash screen stays visible until explicitly hidden
199 by the app.
200 For more information, see
201 \l {QNativeInterface::}{QAndroidApplication::hideSplashScreen()}.
202\row
203 \li android.app.trace_location
204 \li Specifies a location on device where the application can save tracing files.
205 For example: /storage/emulated/0/Android/data/<app_package_name>/files/.
206 This is needed when using Common Trace Format (CTF) tracing backend.
207 \note The application needs storage permission for the location.
208 Default: not set.
209\endtable
210
211\section2 Application Specific Meta-data
212
213Some meta-data attributes are application-wide, and should be placed under
214the \c <application> section:
215
216\table
217\header
218 \li Meta-data Name
219 \li Description
220\row
221 \target android.app.system_libs_prefix
222 \li android.app.system_libs_prefix
223 \li Specifies a custom system library path to use for library loading lookup.
224 This is necessary when using Qt libraries installed outside an app's
225 default native (JNI) library directory.
226 The default value is \c {/system/lib/}.
227\endtable
228
229\section2 Meta-data in Services
230
231Some meta-data attributes can also be used in \l {Android Services}{Services}.
232The main ones are:
233
234\list
235 \li \l {android.app.lib_name}
236 \li \l {android.app.background_running}
237 \li \l {android.app.arguments}
238\endlist
239
240\section2 Qt Permissions and Features
241
242Different Qt modules might require some Android permissions or features to
243function properly, for example, Camera permission in \l {QtMultimedia}.
244l{The androiddeployqt Tool} takes care of including such requirements into the
245Android manifest during the build. Qt defines the following lines into the
246manifest, which they get replaced by
247the actual values:
248
249\badcode
250<manifest ...
251 <!-- %%INSERT_PERMISSIONS -->
252 <!-- %%INSERT_FEATURES -->
253 ...
254</manifest>
255\endcode
256
257\note If those lines are removed from the project manifest, Qt won't be
258able to include the correct permissions. So some functionalities
259might not work properly.
260
261\section2 Style Extraction
262
263Qt uses different methods to determine how Qt Widgets and Qt Quick Controls
264should be styled:
265
266\list
267 \li \c default or \c full: when using Qt Widgets or Qt Quick Controls 1.
268 \note This method uses some Android non-SDK interfaces, that are being
269 restricted and removed by Google starting from Android 9.0 (API 28).
270 For that reason, this is not recommended for Android 9.0 or greater.
271 \li \c minimal: when using Qt Quick Controls 2 and no Qt Widgets or Qt Quick
272 Controls 1. This is faster than using the default or full options.
273 \li \c none: no style extraction.
274\endlist
275
276\section1 Qt Manifest before 6.2 Release
277
278Versions of Qt earlier than 6.2 used to have an additional set of meta-data
279defined by Qt. These attributes used to manage dependencies and some were
280used by the discontinued \c Ministro service. With Qt 6.2, they should be removed.
281Here is a list of these attributes:
282
283\list
284 \li android.app.qt_sources_resource_id
285 \li android.app.repository
286 \li android.app.bundled_libs_resource_id
287 \li android.app.bundle_local_qt_libs
288 \li android.app.use_local_qt_libs
289 \li android.app.libs_prefix
290 \li android.app.load_local_libs_resource_id
291 \li android.app.load_local_jars
292 \li android.app.static_init_classes
293 \li android.app.qt_libs_resource_id
294 \li android.app.ministro_not_found_msg
295 \li android.app.ministro_needed_msg
296 \li android.app.fatal_error_msg
297\endlist
298
299For more information on the Android Manifest, see
300\l{Android: App Manifest}{Android App Manifest}.
301*/