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