androidexported needs to be explicitly specified for activity. Apps targeting Android 12 and higher are required to specify
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Android app development is a rapidly evolving field, with Google frequently updating guidelines and requirements to improve security and user experience. One such recent change affects how app components like <activity>, <service>, and <receiver> are exported. With Android 12 (API level 31) and higher, it is mandatory for developers to explicitly specify the android:exported attribute for <activity> components. This provides clarity on the accessibility of the components within an app's manifest, making it an essential part of modern Android development.
Understanding android:exported
The android:exported attribute determines whether a component such as an activity is accessible by other applications. Its value can be set to true or false:
android:exported="true": This means the component is accessible to other applications. This setting should be used with caution as it can potentially expose app functionality or data to other apps.android:exported="false": The component is private and can only be accessed by components within the same application or by those with the same user ID.
Why Specify android:exported?
With previous versions of Android, the value of android:exported was often inferred based on the presence of certain intent filters. However, this could lead to ambiguity and unintentional exposure of components. By requiring explicit specification from Android 12 onward, Google aims to enforce more secure and predictable app behaviors.
Examples
Before Android 12 (Ambiguity)
In this example, before Android 12, the absence of android:exported would default to true, potentially exposing the component without explicit consent from the developer.
Android 12 and Higher (Explicitness)
Here, android:exported is explicitly set to true, clarifying that the activity is intended to be accessible by other apps. This is a mandatory specification for apps targeting Android 12 and above.
Key Points Summary
| Attribute | Description | Importance |
android:exported | Determines if a component is accessible to other applications. | Mandatory for apps targeting Android 12+. |
true | Component is accessible by other apps. | Use with caution to avoid unintentional data exposure. |
false | Component is only accessible within the same application. | Preferable for sensitive components that should not be exposed publicly. |
| Intent Filters | Used to declare the kinds of intents an activity, service, or receiver can respond to. | Can implicitly affect the android:exported state before Android 12. |
| Explicit Spec | Reduces ambiguity and increases app security by requiring explicit declaration in the manifest. | Encourages developers to be mindful of component accessibility and security. |
Best Practices
- Review your Manifest: Developers targeting Android 12 and above should review and update their AndroidManifest.xml to ensure all components explicitly declare their
android:exportedstatus. - Security Considerations: Careful consideration is essential when setting
android:exportedtotrue. Limit exposure to components that must interact with components of other applications. - Testing: Thoroughly test your application after updating the manifest to ensure that all components behave as intended and that no functionality is inadvertently broken by these changes.
- Documentation: Keep comprehensive documentation for your manifest setup. With clear documentation, team members can understand and maintain security policies and component access logic.
- Stay Updated: Android OS changes are frequent. Ensure continuous learning and adjustments to align with the latest security standards.
By adopting these best practices, developers can navigate the transition confidently and maintain secure, well-functioning applications in line with Android's evolving guidelines.
In summary, the requirement to explicitly specify android:exported for activities (and other components) in Android 12+ is a critical enhancement for app security and clarity. Ensuring components have explicitly defined access controls protects user data and maintains the integrity of the app ecosystem.

