Explain the use of AndroidManifest.xml in an Android application.
Instruction: Describe the purpose of the AndroidManifest.xml file and list some of the key information it contains.
Context: This question assesses the candidate's knowledge of the AndroidManifest.xml file's role as a critical component in Android app development, including its use for defining the app's structure, core components (activities, services, broadcast receivers, and content providers), permissions, and other application-level settings.
Updated
Official answer
AndroidManifest.xml describes the application to Android's build tools, operating system and distribution tooling. The packaged app uses a merged manifest assembled from the app, build variants and relevant libraries, so inspect the merged result when debugging a declaration.
Its key responsibilities include:
- Components: declare activities, services, content providers and manifest-registered broadcast receivers, including their classes and intent filters. A context-registered receiver is registered at runtime instead of through a manifest receiver declaration.
- Permissions: declare requested permissions with
uses-permissionand permissions that protect exposed components. Declaration alone does not show a runtime permission dialog or grant every permission. Request applicable runtime permissions through the permission API and handle denial. - Exposure: set component export and permission rules deliberately. For apps targeting Android 12 or later, activities, services and receivers with intent filters must explicitly declare
android:exported. A launcher activity needs to be discoverable; internal components should not be exported without a reason. An intent filter is not an authorization check. - Application and device requirements: configure relevant application metadata, labels, themes and features. A
uses-featuredeclaration expresses a device capability requirement; auses-permissiondeclaration requests access. These serve different purposes. - SDK compatibility: in a Gradle-based app, configure minimum and target SDK values in the build configuration; those values override corresponding manifest settings. Targeting a newer SDK does not make its APIs available on an older device.
Check the merged manifest for unintended library permissions or exported components, then test required and denied access on the supported OS versions.
Sources
Android app manifest overview; broadcast registration; Android 12 component export requirements.
Related Questions
-
easy
-
easy
-
easy
-
hard