summaryrefslogtreecommitdiffstats
path: root/src/android/templates/doc/src/android-manifest-file-configuration.qdoc
blob: c784040f459c39ff0a780951e4d34fbb1a90ff1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
\page android-manifest-file-configuration.html
\title Qt Android Manifest File Configuration
\ingroup androidplatform
\brief Provides details on the AndroidManifest.xml configuration.
\previouspage android-openssl-support.html
\nextpage android-services.html

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 \c {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.

\section1 Qt Project to Manifest Configuration

Qt defines some \l {Android: App Manifest <meta-data>}{meta-data} that is passed
from the build systems and to \l {Deploying an Application on Android}{androiddeployqt}
which populates the manifest with the correct values without explicitly setting
these in the manifest file. Such \l {Android: App Manifest <meta-data>}{meta-data}
is assigned a value in the form \c {"-- %%INSERT_VALUE%% --"}, for example:

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

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

\section1 Qt Default Configuration

Qt sets the following manifest configuration by default:

\table
\header
    \li Section
    \li Option
    \li Description
\row
    \li {1, 5} \l {Android: App Manifest <manifest>}{<manifest>}
    \li package
    \li Sets the package name. The default value is \c {org.qtproject.example.app_name}.
\row
    \li \c {android:installLocation}
    \li Sets the app's installation location, whether internal or external storage.
        The default value is \c auto.
\row
    \li android:versionCode
    \li Sets the internal version code. Populated from \c ANDROID_VERSION_CODE (qmake)
        and \c QT_ANDROID_VERSION_CODE (CMake). The default value is \c 1.
\row
    \li android:versionName
    \li Sets the public version name. Populated from \c ANDROID_VERSION_NAME (qmake)
        and \c QT_ANDROID_VERSION_NAME (CMake). The default value is \c {1.0}.
\row
    \li \c {<supports-screens>}
    \li Sets the screen sizes that the app supports,
        default values are \c anyDensity, \c largeScreens,
        \c normalScreens, and \c smallScreens.
\row
    \li {1, 8} \l {Android: App Manifest <application>}{<application>}
    \li android:name
    \li The application class name. Default value is
        \c {org.qtproject.qt.android.bindings.QtApplication}.
\row
    \li android:label
    \li The application name label. Default value is the Qt project's target name.
\row
    \li android:hardwareAccelerated
    \li Sets hardware acceleration preference. The default value is \c true.
\row
    \li android:requestLegacyExternalStorage
    \li Whether to use Android scoped storage. The default value is \c true.
\row
    \li android:allowNativeHeapPointerTagging
    \li Whether or not the app has the Heap pointer tagging feature enabled.
        This has to be set to \c false when targeting Arm64 hardware with Android 11+
        because it can break QML's NaN-tagging scheme.
        For more information, see \l {Android: Tagged Pointers}{Tagged Pointers}.
        The default value is \c false.
\row
    \li android:allowBackup
    \li Whether to allow the application to participate in the backup and restore
        infrastructure. If this is set to \c false, no backup or restore of the
        application will ever be performed. The default value is \c true.
\row
    \li android:fullBackupOnly
    \li Whether or not to use Auto Backup on devices where it is available.
        The default value is \c false.
\row
    \li {1, 7} \l {Android: App Manifest <activity>}{<activity>}
    \li android:name
    \li The activity class name. The default value is \c {org.qtproject.qt.android.bindings.QtActivity}.
\row
    \li android:label
    \li The activity name label. Default value is the Qt project's target name.
\row
    \li android:configChanges
    \li Lists configuration changes that the activity handles. Default value is
        \c orientation, \c uiMode, \c screenLayout, \c screenSize,
        \c smallestScreenSize, \c layoutDirection, \c locale, \c fontScale,
        \c keyboard, \c keyboardHidden, \c navigation, \c mcc, \c mnc, \c density.
\row
    \li android:launchMode
    \li The method used to launch the activity. The default value is \c singleTop.
\row
    \li android:screenOrientation
    \li The orientation of the activity's display on the device. The default value is \c unspecified.
\row
    \li <intent-filter>
    \li Specifies the types of intents that the activity can respond to. Default value is
        \badcode
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
        \endcode
\row
    \li android:exported
    \li Sets whether the activity can be launched by components of other applications.
        The default value is \c true.
\endtable

\section1 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 \c <activity> section in the form:

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

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

\table
\header
    \li Meta-data Name
    \li Description
\row
    \target android.app.lib_name
    \li android.app.lib_name
    \li The filename of the native C++ library that is used by the activity.
        \note This attribute is mandatory and shouldn't be removed.
        Default value is the Qt project's target name.
\row
    \li android.app.extract_android_style
    \li The method used to extract the native Android Style information.
        For more information, see \l {Style Extraction}.
        The default value is \c minimal.
\row
    \target android.app.background_running
    \li android.app.background_running
    \li Sets whether the app keeps running tasks in the background.
        Setting this to \c true is the equivalent of setting the environment
        variable \c QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED to \c 0.
        The default value is \c false.

        \warning Setting this to \c true may cause unexpected crash if the
        application tries to draw after \l {QGuiApplication::applicationStateChanged()}
        signal is sent with a \l {Qt::ApplicationSuspended} state.
\row
    \target android.app.arguments
    \li android.app.arguments
    \li Sets a list of arguments to pass to the app \c {"arg1 arg2"}.
        Populated from \c ANDROID_APPLICATION_ARGUMENTS (qmake) and
        \c QT_ANDROID_APPLICATION_ARGUMENTS (CMake).
        Default value is not set.
\row
    \li android.app.splash_screen_drawable_portrait
    \li Sets a drawable for a splash screen specific to portrait mode.
        For example: \c {android:resource="@drawable/splash_portrait"}.
        Default value is not set.
\row
    \li android.app.splash_screen_drawable_landscape
    \li Sets a drawable for a splash screen specific to landscape mode.
        For example: \c {android:resource="@drawable/splash_landscape"}.
        Default value is not set.
\row
    \li android.app.splash_screen_drawable
    \li Sets 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: \c {android:resource="@drawable/splash"}.
        Default value is not set.
\row
    \li android.app.splash_screen_sticky
    \li Sets whether the splash screen stays visible until explicitly hidden
        by the app.
        For more information, see
        \l {QNativeInterface::}{QAndroidApplication::hideSplashScreen()}.
\endtable

\section2 Application Specific Meta-data

Some meta-data attributes are application-wide, and should be placed under
the \c <application> section:

\table
\header
    \li Meta-data Name
    \li Description
\row
    \target android.app.system_libs_prefix
    \li android.app.system_libs_prefix
    \li Specifies a custom system library path to use for library loading lookup.
        This is necessary when using Qt libraries installed outside an app's
        default native (JNI) library directory.
        The default value is \c {/system/lib/}.
\endtable

\section2 Meta-data in Services

Some meta-data attributes can also be used in \l {Android Services}{Services}.
The main ones are:

\list
    \li \l {android.app.lib_name}
    \li \l {android.app.background_running}
    \li \l {android.app.arguments}
\endlist

\section2 Qt Permissions and Features

Different Qt modules might require some Android permissions or features to
function properly, for example, Camera permission in \l {QtMultimedia}.
l{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:

\badcode
<manifest ...
    <!-- %%INSERT_PERMISSIONS -->
    <!-- %%INSERT_FEATURES -->
    ...
</manifest>
\endcode

\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.

\section2 Style Extraction

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

\list
    \li \c default or \c 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.
    \li \c 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.
    \li \c none: no style extraction.
\endlist

\section1 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 \c Ministro service. With Qt 6.2, they should be removed.
Here is a list of these attributes:

\list
    \li android.app.qt_sources_resource_id
    \li android.app.repository
    \li android.app.bundled_libs_resource_id
    \li android.app.bundle_local_qt_libs
    \li android.app.use_local_qt_libs
    \li android.app.libs_prefix
    \li android.app.load_local_libs_resource_id
    \li android.app.load_local_jars
    \li android.app.static_init_classes
    \li android.app.qt_libs_resource_id
    \li android.app.ministro_not_found_msg
    \li android.app.ministro_needed_msg
    \li android.app.fatal_error_msg
\endlist

For more information on the Android Manifest, see
\l{Android: App Manifest}{Android App Manifest}.
*/