In the Androidmanifest.xml file, you first see the Yes <manifest> node, which is the basic property of the entire application, covering the default process name, application identity, installation location, requirements for the system, and the version of the application. It is the root node of the Androidmanifest.xml file, which must contain a <application> node, and must specify the Xmlns:android and package properties, as shown in the following code:
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "string"
Android:shareduserid= "string"
Android:shareduserlabel= "String Resource"
Android:versioncode= "Integer"
Android:versionname= "string"
android:installlocation=["Auto" | " Internalonly "|" Preferexternal "]>
.............
</manifest>
It is important to note that, in the many properties described above, except for the xmlns and package nodes, the rest are optional nodes, and Android gives them the default values. Next, let's describe in detail the meanings and effects of these attributes in the <manifest> node.
1.xmlns:android Properties--Define namespaces
This attribute defines the namespace used by this XML file. If you need to specify a special namespace, you need to write the code manually, with the following basic format:
xmlns:< namespace Identity >= "http://schemas.android.com/apk/res/< full package name >"
Note: The <> part of the code must be filled in, and never be missed!
We'll start with the almighty HelloWorld, open up the latest Android development tools for Android Studio, create a project called HelloWorld, and the project will automatically generate Androidmanifest.xml files, let's look at its structure.
If "identity" does not match, the resulting result is as follows:
Error message:
The package name of the resource is a Java package name that must exist, and if it does not exist, it will also make an error.
See the solution, everyone understand it! Identity and resource package name must be unified, can not be written with the nature, or no matter how the toss can only be in situ. Remember!
2.package Properties-The application's identity card
The Package property uniquely identifies an application. Note that it is unique! Again, it is the default name for the application process and the default task (taskaffinity) for each activity in the application. Normally, when we finish creating it, it has a default value. So where do these default names come from? Such as:
Run this program and the Android device will start a process like this for this app, such as:
Did you see it clearly? Speaking of which, you might have an idea: what happens if I install another application with the same package attribute? The following error is indicated:
Failure[install_failed_already_exsist]
Note: It is not recommended to modify the value of the package property unless special needs are required! The reason is that the package is the only property that identifies our application, and if you try to change its value, then the system will generally think of it as a different application, causing users with the previous version of the application to be unable to own the new version of the application.
3.android:shareduserid Properties--sharing data
This attribute defines the Linux user ID that needs to be shared with other applications. By default, the Android system assigns a unique user ID to each application. However, when this property is set to the same value in multiple applications, they will share a user ID. The advantage of this is that they can access each other's data, and if necessary, they will also run in the same process. The HelloWorld app does not set this property, which means that it does not have a shared relationship with other applications, so that they need to exchange data through other means, such as interprocess communication.
The properties associated with the Android:shareduserid property are also Android:shareduserlabel, which defines a user-readable label for the shared user ID. This tag must be set with a string resource and cannot use a native string. This property is referenced in API LEVEL3 and only makes sense if the Shareduserid attribute is set.
4.android:versioncode Property--build number
The value of the Android:versioncode property is a build number that determines whether this version is newer than the other version, and the larger the number, the more new it is. It is not the version number that is displayed to the user, but the number set by the Versionname property. The version number determines the behavior of some services, such as whether to perform a backup restore operation when replacing the application.
The number must be set to an integer, such as 100. In addition, we can define this integer as much as you want, as long as each successive version can have a larger number. For example, it can be a compilation number.
5.android:versionname Property--The version number that is displayed to the user
The value of the Android:versionname property is the version number that is displayed to the user, which can be set to either an original string or a reference to a string resource. This string has no other purpose than to show it to the user. In HelloWorld, the version number that is displayed to the user is 1.0, such as:
6.android:installlocation Properties--Installation location
This property defines the default installation location for the application, with a total of 3 optional values in the form of the following:
android:installlocation=["Auto" | " Internalonly "|" Preferexternal "]
The following table describes the meanings of these 3 optional values.
| Value |
Describe |
| Auto |
The application may be installed on an external storage device, but by default the application will be installed on the internal storage device. If there is not enough memory, the system will install the application on an external storage device. |
| Internalonly |
The application must be installed on the device's internal storage device. If this value is set, it means that the application will never be installed on an external storage device. If there is not enough memory, then the system will not install this apk. If the Android:installlocation property is not set, Internalonly is the default value for the property. |
| Preferexternal |
The application will be installed on an external storage device, and if the system does not support an external storage device or the external device is full, the system will install the application on the internal storage device. |
Android inventory file (a)----everything starts with <manifest>