Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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 \Q4A 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
12
The Android Manifest is an XML file necessary for any Android app. It contains
13
app configuration for different settings and features that the app uses, as well
14
as details on the app itself, such as, package name, app name, version, etc.
15
Permissions and hardware features can also be set from the manifest.
16
17
\Q4A maintains a version of \c {AndroidManifest.xml} with default
18
configuration that include features, permissions and other configuration
19
used by the build system which are needed for building and running Qt apps
20
on Android.
21
22
\section1 Qt Project to Manifest Configuration
23
24
Qt defines some \l {Android: App Manifest <meta-data>}{meta-data} that is passed
25
from the build systems and to \l {Deploying an Application on Android}{androiddeployqt}
26
which populates the manifest with the correct values without explicitly setting
27
these in the manifest file. Such \l {Android: App Manifest <meta-data>}{meta-data}
28
is 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
37
This would be populated with the version code that is set in, for example,
38
\c CMake.
39
40
\section1 Qt Default Configuration
41
42
Qt 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
\warning This field is deprecated and moved to \c build.gradle. It will be removed
54
in an upcoming release.
55
\row
56
\li android:installLocation
57
\li Sets the app's installation location, whether internal or external storage.
58
The default value is \c auto.
59
\row
60
\li android:versionCode
61
\li Sets the internal version code. Populated from \c ANDROID_VERSION_CODE (qmake)
62
and \c QT_ANDROID_VERSION_CODE (CMake). The default value is \c 1.
63
\row
64
\li android:versionName
65
\li Sets the public version name. Populated from \c ANDROID_VERSION_NAME (qmake)
66
and \c QT_ANDROID_VERSION_NAME (CMake). The default value is \c {1.0}.
67
\row
68
\li <supports-screens>
69
\li Sets the screen sizes that the app supports,
70
default values are \c anyDensity, \c largeScreens,
71
\c normalScreens, and \c smallScreens.
72
\row
73
\li {1, 4} \l {Android: App Manifest <application>}{<application>}
74
\li android:name
75
\li The application class name. Default value is
76
\c {org.qtproject.qt.android.bindings.QtApplication}.
77
\row
78
\li android:label
79
\li The application name label. Default value is the Qt project's target name.
80
This can be set using \l {QT_ANDROID_APP_NAME}.
81
\row
82
\li android:icon
83
\li The application icon as a reference to a drawable or mipmap resource. This
84
tag is not used unless set using \l {QT_ANDROID_APP_ICON} or set manually
85
in the \c {AndroidManifest.xml}.
86
\row
87
\li android:hardwareAccelerated
88
\li Sets hardware acceleration preference. The default value is \c true.
89
\row
90
\li {1, 6} \l {Android: App Manifest <activity>}{<activity>}
91
\li android:name
92
\li The activity class name. The default value is \c {org.qtproject.qt.android.bindings.QtActivity}.
93
\row
94
\li android:configChanges
95
\li Lists configuration changes that the activity handles. Default value is
96
\c orientation, \c uiMode, \c screenLayout, \c screenSize,
97
\c smallestScreenSize, \c layoutDirection, \c locale, \c fontScale,
98
\c keyboard, \c keyboardHidden, \c navigation, \c mcc, \c mnc, \c density.
99
\row
100
\li android:launchMode
101
\li The method used to launch the activity. The default value is \c singleTop.
102
\row
103
\li android:screenOrientation
104
\li The orientation of the activity's display on the device. The default value is \c unspecified.
105
\row
106
\li <intent-filter>
107
\li Specifies the types of intents that the activity can respond to. Default value is
108
\badcode
109
<action android:name="android.intent.action.MAIN"/>
110
<category android:name="android.intent.category.LAUNCHER"/>
111
\endcode
112
\row
113
\li android:exported
114
\li Sets whether the activity can be launched by components of other applications.
115
The default value is \c true.
116
\endtable
117
118
\target android-manifest-qt-specific-metadata
119
\section1 Qt Specific Meta-data
120
121
In addition to the default manifest configuration that Qt sets, Qt defines
122
some meta-data that is valid for Qt apps only. Such meta-data is usually
123
under the \c <activity> section in the form:
124
125
\badcode
126
<meta-data
127
android:name="meta-data-name"
128
android:value="meta-data-value" />
129
\endcode
130
131
The following is a list of such meta-data defined by Qt:
132
133
\table
134
\header
135
\li Meta-data Name
136
\li Description
137
\row
138
\li android.app.lib_name \target android.app.lib_name
139
\li The filename of the native C++ library that is used by the activity.
140
\note This attribute is mandatory and shouldn't be removed.
141
Default value is the Qt project's target name.
142
\row
143
\li android.app.extract_android_style
144
\li The method used to extract the native Android Style information.
145
For more information, see \l {Style Extraction}.
146
The default value is \c minimal.
147
\row
148
\li android.app.background_running \target android.app.background_running
149
\li Sets whether the app keeps running tasks in the background.
150
Setting this to \c true is the equivalent of setting the environment
151
variable \c QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED to \c 0. The variable
152
blocks for a non-zero integer or \c true, and doesn't block otherwise.
153
The default value is \c false.
154
155
\warning Setting this to \c true may cause unexpected crash if the
156
application tries to draw after \l {QGuiApplication::applicationStateChanged()}
157
signal is sent with a \l {Qt::ApplicationSuspended} state.
158
\row
159
\li android.app.arguments \target android.app.arguments
160
\li Sets a list of arguments to pass to the app \c {"arg1 arg2"}.
161
Populated from \c ANDROID_APPLICATION_ARGUMENTS (qmake) and
162
\c QT_ANDROID_APPLICATION_ARGUMENTS (CMake).
163
Default value is not set.
164
\row
165
\li android.app.splash_screen_drawable_portrait
166
\li Sets a drawable for a splash screen specific to portrait mode.
167
For example: \c {android:resource="@drawable/splash_portrait"}.
168
Default value is not set.
169
\row
170
\li android.app.splash_screen_drawable_landscape
171
\li Sets a drawable for a splash screen specific to landscape mode.
172
For example: \c {android:resource="@drawable/splash_landscape"}.
173
Default value is not set.
174
\row
175
\li android.app.splash_screen_drawable
176
\li Sets a drawable for a splash screen at the start of the app.
177
\note Orientation specific splash screens are checked first,
178
if not set, this is used instead.
179
For example: \c {android:resource="@drawable/splash"}.
180
Default value is not set.
181
\row
182
\li android.app.splash_screen_sticky
183
\li Sets whether the splash screen stays visible until explicitly hidden
184
by the app.
185
For more information, see
186
\l {QNativeInterface::}{QAndroidApplication::hideSplashScreen()}.
187
\row
188
\li android.app.trace_location
189
\li Specifies a location on device where the application can save tracing files.
190
For example: /storage/emulated/0/Android/data/<app_package_name>/files/.
191
This is needed when using Common Trace Format (CTF) tracing backend.
192
\note The application needs storage permission for the location.
193
Default: not set.
194
\endtable
195
196
\section2 Application Specific Meta-data
197
198
Some meta-data attributes are application-wide, and should be placed under
199
the \c <application> section:
200
201
\table
202
\header
203
\li Meta-data Name
204
\li Description
205
\row
206
\li android.app.system_libs_prefix \target android.app.system_libs_prefix
207
\li Specifies a custom system library path to use for library loading lookup.
208
This is necessary when using Qt libraries installed outside an app's
209
default native (JNI) library directory.
210
The default value is \c {/system/lib/}.
211
\note Set this only to a directory that untrusted code cannot write
212
to. Qt loads native libraries and plugins from this directory
213
without verifying them, so any code placed there runs with the
214
application's permissions.
215
216
\endtable
217
218
\section2 Meta-data in Services
219
220
Some meta-data attributes can also be used in \l {Android Services}{Services}.
221
The main ones are:
222
223
\list
224
\li \l {android.app.lib_name}
225
\li \l {android.app.background_running}
226
\li \l {android.app.arguments}
227
\endlist
228
229
\section2 Qt Permissions and Features
230
231
Different Qt modules might require some Android permissions or features to
232
function properly, for example, Camera permission in \l {QtMultimedia}.
233
\l{The androiddeployqt Tool} takes care of including such requirements into the
234
Android manifest during the build. Qt defines the following lines into the
235
manifest, which they get replaced by
236
the actual values:
237
238
\badcode
239
<manifest ...
240
<!-- %%INSERT_PERMISSIONS -->
241
<!-- %%INSERT_FEATURES -->
242
...
243
</manifest>
244
\endcode
245
246
\note If those lines are removed from the project manifest, Qt won't be
247
able to include the correct permissions. So some functionalities
248
might not work properly.
249
250
\section3 Customizing Permissions
251
252
Since Qt 6.8.1, it is possible to override the default permissions set
253
by Qt modules. This is useful if you need to define the same permissions
254
as used by a Qt module, but with additional or different attributes.
255
256
There are two ways to achieve this. First way is to use
257
\l {qt_add_android_permission} CMake function in the application's
258
\c {CMakeLists.txt}. Permissions defined this way take precedence over
259
the same permissions defined by Qt modules, avoiding duplication.
260
261
Second way is to manually define these permissions in the Android
262
manifest file. Permissions defined this way take precedence over permissions
263
set by Qt modules, or set with \l {qt_add_android_permission}.
264
265
\section2 Style Extraction
266
267
Qt uses different methods to determine how Qt Widgets and Qt Quick Controls
268
should be styled:
269
270
\list
271
\li \c full: when using Qt Widgets or Qt Quick Controls 1.
272
\note This method is obsolete as it uses some Android non-SDK interfaces, that were
273
restricted by Google starting from Android 9.0 (API 28). You should use one of the other methods.
274
\li \c default or \c minimal: when using Qt Quick Controls 2 and no Qt Widgets or Qt Quick
275
Controls 1. This is faster than using the default or full options.
276
\li \c none: no style extraction.
277
\endlist
278
279
\section1 Qt Manifest before 6.2 Release
280
281
Versions of Qt earlier than 6.2 used to have an additional set of meta-data
282
defined by Qt. These attributes used to manage dependencies and some were
283
used by the discontinued \c Ministro service. With Qt 6.2, they should be removed.
284
Here is a list of these attributes:
285
286
\list
287
\li android.app.qt_sources_resource_id
288
\li android.app.repository
289
\li android.app.bundled_libs_resource_id
290
\li android.app.bundle_local_qt_libs
291
\li android.app.use_local_qt_libs
292
\li android.app.libs_prefix
293
\li android.app.load_local_libs_resource_id
294
\li android.app.load_local_jars
295
\li android.app.static_init_classes
296
\li android.app.qt_libs_resource_id
297
\li android.app.ministro_not_found_msg
298
\li android.app.ministro_needed_msg
299
\li android.app.fatal_error_msg
300
\endlist
301
302
For more information on the Android Manifest, see
303
\l{Android: App Manifest}{Android App Manifest}.
304
*/
qtbase
src
android
templates
doc
src
android-manifest-file-configuration.qdoc
Generated on
for Qt by
1.18.0