Why did your app suddenly stop launching on Android 12?
\n\nYou updated targetSdkVersion to 31 or higher, built the APK, launched it — and got a crash with a mysterious message:
android:exported needs to be explicitly specified for <activity>. \nApps targeting Android 12 and higher are required to specify \nan explicit value for `android:exported` when the corresponding \ncomponent has an intent filter defined.\n\nSound familiar? If you've checked Stack Overflow, you've seen this question has thousands of views. Developers are panicking, and users are confused. But don't rush to delete your project. In this article, we'll figure out what this android:exported beast is, why Google tightened the requirements, and how to quickly fix the error in Kotlin. Let's go!
What is android:exported and why is it needed?
\n\nandroid:exported is an attribute in AndroidManifest.xml that controls whether other applications (or the system itself) can launch your component (Activity, Service, BroadcastReceiver, or ContentProvider). If the attribute is set to true — the component is accessible from outside. If false — only within your app.
Before Android 12 (API 31), this attribute was optional. If you didn't specify it, the system decided for itself whether the component was accessible:
\n- \n
- If an Activity has an
<intent-filter>— the system consideredexported = true. \n - If there is no filter —
exported = false. \n
But this "automatic" behavior is a security hole. Imagine: you wrote an Activity for logging into an app and accidentally added an intent-filter. Any third-party app can call your Activity and steal tokens. So Google decided: starting with Android 12, you must explicitly specify android:exported for any component that has an <intent-filter>.
What does the error look like in practice?
\n\nSuppose you have a simple manifest:
\n\n<activity android:name=".MainActivity">\n <intent-filter>\n <action android:name="android.intent.action.MAIN" />\n <category android:name="android.intent.category.LAUNCHER" />\n </intent-filter>\n</activity>\n\nIf targetSdkVersion = 31 or higher, you will get an error during compilation or launch. The solution is to add android:exported:
<activity \n android:name=".MainActivity"\n android:exported="true">\n <intent-filter>\n <action android:name="android.intent.action.MAIN" />\n <category android:name="android.intent.category.LAUNCHER" />\n </intent-filter>\n</activity>\n\nFor the main Activity that launches from the home screen, exported must be true — otherwise, the launcher won't be able to open it.
How to fix it correctly: step-by-step instructions
\n\nStep 1. Open AndroidManifest.xml
\nFind all <activity>, <service>, <receiver>, and <provider> that have an <intent-filter>. For each of them, add android:exported.
Step 2. Determine the attribute value
\nHere's a simple rule:
\n- \n
- true — if the component should be accessible from other apps (e.g., Activity for Google sign-in, BroadcastReceiver for system events, main Activity with the LAUNCHER filter). \n
- false — if the component is used only within your app (e.g., an Activity that opens when a button is clicked in your own code). \n
Step 3. Examples for different scenarios
\n\nScenario 1: Main Activity (Launcher)
\n