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 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%% --"
,例如:
<manifest ... android:versionCode="-- %%INSERT_VERSION_CODE%% --" ... </manifest>
This would be populated with the version code that is set in, for example,
CMake
.
Qt sets the following manifest configuration by default:
Section | 选项 | 描述 |
---|---|---|
<manifest> | 包 |
Sets the package name. The default value is
org.qtproject.example.app_name
.
|
android:installLocation
|
Sets the app's installation location, whether internal or external storage. The default value is
auto
.
|
|
android:versionCode |
Sets the internal version code. Populated from
ANDROID_VERSION_CODE
(qmake) and
QT_ANDROID_VERSION_CODE
(CMake). The default value is
1
.
|
|
android:versionName |
Sets the public version name. Populated from
ANDROID_VERSION_NAME
(qmake) and
QT_ANDROID_VERSION_NAME
(CMake). The default value is
1.0
.
|
|
<supports-screens>
|
Sets the screen sizes that the app supports, default values are
anyDensity
,
largeScreens
,
normalScreens
,和
smallScreens
.
|
|
<application> | android:name |
The application class name. Default value is
org.qtproject.qt.android.bindings.QtApplication
.
|
android:label | The application name label. Default value is the Qt project's target name. | |
android:hardwareAccelerated |
Sets hardware acceleration preference. The default value is
true
.
|
|
android:requestLegacyExternalStorage |
Whether to use Android scoped storage. The default value is
true
.
|
|
android:allowNativeHeapPointerTagging |
Whether or not the app has the Heap pointer tagging feature enabled. This has to be set to
false
when targeting Arm64 hardware with Android 11+ because it can break QML's NaN-tagging scheme. For more information, see
Tagged Pointers
。默认值为
false
.
|
|
android:allowBackup |
Whether to allow the application to participate in the backup and restore infrastructure. If this is set to
false
, no backup or restore of the application will ever be performed. The default value is
true
.
|
|
android:fullBackupOnly |
Whether or not to use Auto Backup on devices where it is available. The default value is
false
.
|
|
<activity> | android:name |
The activity class name. The default value is
org.qtproject.qt.android.bindings.QtActivity
.
|
android:label | The activity name label. Default value is the Qt project's target name. | |
android:configChanges |
Lists configuration changes that the activity handles. Default value is
orientation
,
uiMode
,
screenLayout
,
screenSize
,
smallestScreenSize
,
layoutDirection
,
locale
,
fontScale
,
keyboard
,
keyboardHidden
,
navigation
,
mcc
,
mnc
,
density
.
|
|
android:launchMode |
The method used to launch the activity. The default value is
singleTop
.
|
|
android:screenOrientation |
The orientation of the activity's display on the device. The default value is
unspecified
.
|
|
<intent-filter> |
Specifies the types of intents that the activity can respond to. Default value is
<action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> |
|
android:exported |
Sets whether the activity can be launched by components of other applications. The default value is
true
.
|
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 Name | 描述 |
---|---|
android.app.lib_name |
The filename of the native C++ library that is used by the activity. 注意: This attribute is mandatory and shouldn't be removed. Default value is the Qt project's target name. |
android.app.extract_android_style |
The method used to extract the native Android Style information. For more information, see
样式提取
。默认值为
minimal
.
|
android.app.background_running |
Sets 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
。默认值为
false
.
警告:
Setting this to
|
android.app.arguments |
Sets a list of arguments to pass to the app
"arg1 arg2"
. Populated from
ANDROID_APPLICATION_ARGUMENTS
(qmake) and
QT_ANDROID_APPLICATION_ARGUMENTS
(CMake). Default value is not set.
|
android.app.splash_screen_drawable_portrait |
Sets a drawable for a splash screen specific to portrait mode. For example:
android:resource="@drawable/splash_portrait"
. Default value is not set.
|
android.app.splash_screen_drawable_landscape |
Sets a drawable for a splash screen specific to landscape mode. For example:
android:resource="@drawable/splash_landscape"
. Default value is not set.
|
android.app.splash_screen_drawable |
Sets a drawable for a splash screen at the start of the app.
注意:
Orientation specific splash screens are checked first, if not set, this is used instead. For example:
|
android.app.splash_screen_sticky | Sets whether the splash screen stays visible until explicitly hidden by the app. For more information, see QAndroidApplication::hideSplashScreen (). |
android.app.trace_location |
Specifies a location on device where the application can save tracing files. For example: /storage/emulated/0/Android/data/<app_package_name>/files/. This is needed when using Common Trace Format (CTF) tracing backend. 注意: The application needs storage permission for the location. Default: not set. |
Some meta-data attributes are application-wide, and should be placed under the
<application>
section:
Meta-data Name | 描述 |
---|---|
android.app.system_libs_prefix |
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
/system/lib/
.
|
Some meta-data attributes can also be used in Services . The main ones are:
Different Qt modules might require some Android permissions or features to function properly, for example, Camera permission in 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:
<manifest ... <!-- %%INSERT_PERMISSIONS --> <!-- %%INSERT_FEATURES --> ... </manifest>
注意: 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.
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.
注意: 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.
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:
For more information on the Android Manifest, see Android App Manifest .
为 Android 添加 OpenSSL 支持 Android 服务