Android Manifest Architecture: Configuration, Libraries, and Permissions
Hardware Configuration Requirements
Applications define required hardware capabilities using <uses-configuration>. This prevents installation on devices lacking essential inputs. It is recommended to support directional keys for accessibility, or alternatively declare touch requirements via <uses-feature> to better control filter behavior across touch types.
<!-- Specify input method prerequisites -->
<uses-configuration
android:reqFiveWayNav="true"
android:reqHardKeyboard="false"
android:reqKeyboardType="qwerty"
android:reqNavigation="dpad"
android:reqTouchScreen="finger" />
Configuration Attributes:
android:reqFiveWayNav: Boolean. Indicates necessity of a central select button with directional movement (up/down/left/right/dpad). OverridesreqNavigationif used generically.android:reqHardKeyboard: Boolean. Enforces presence of a physical QWERTY-style keypad.android:reqKeyboardType: Enum. Specifies keyboard layout (nokeys,qwerty,twelvekey,undefined). Does not distinguish betwean physical and virtual layouts.android:reqNavigation: Enum. Defines navigation hardware (nonav,dpad,trackball,wheel,undefined).android:reqTouchScreen: Enum. Requires touch interaction (stylus,finger,notouch). Prefer<uses-feature>for detailed touch event capabilities.
Shared Library Management
To enforce dependency on external system libraries, use <uses-library> within the Application scope. This element adds class loaders for specific libraries and affects availability on the distribution platform. If android:required="true" is set, the Package Manager blocks installation on devices missing the library.
<!-- Define critical shared resources -->
<uses-library
android:name="com.google.android.maps"
android:required="true" />
android:name: Identifies the library package path. Reference official docs to find available system libraries.android:required: Boolean defaulting totrue. Set tofalseto allow installation without the library, provided runtime checks verify its existence before usage.
System Permission Declarations
Permissions listed here dictate system privileges needed at install time or launch time. Declare hardware-sensitive permissions explicitly via <uses-feature> to manage Google Play filtering accurately, rather than relying on implicit inference.
<!-- Request restricted access scopes -->
<uses-permission
android:name="android.permission.CAMERA"
android:maxSdkVersion="20" />
android:name: String identifier for the permission (e.g.,READ_CONTACTS).android:maxSdkVersion: Integer limit. Useful for legacy permissions dropped in later releases. For instance, external file writes might only be mandatory up to API level 19. Omitting this ensures compliance across all versions unless specifically targeted.
API Level Specific Permissions
For features introduced alongside Android 6.0, use <uses-permission-sdk-23>. This ensures permissions are requested only on devices supporting runtime grant mechanisms (SDK 23+). On older systems, these declarations are ignored, preventing unnecessary upgrade barriers.
<!-- Handle modern permission models conditionally -->
<uses-permission-sdk-23
android:name="android.permission.RECORD_AUDIO"
android:maxSdkVersion="25" />
android:name: The specific permission identifier required.android:maxSdkVersion: The upper bound for API levels where this permission remains active for the app.