The android:exported
attribute sets whether a component (activity, service, broadcast receiver, etc.) can be launched by components of other applications:
- If true, any app can access the activity and launch it by its exact class name.
- If false, only components of the same application, applications with the same user ID, or privileged system components can launch the activity.
The logic behind the default value of this attribute changed over time and was different depending on the component types and Android versions. For example, on API level 16 (Android 4.1.1) or lower the value for elements is set to true by default. Not setting this attribute explicitly carries the risk of having different default values between some devices.
Taken from the official documentation
Things changed since Android 12 devices, so you need to do these things:
Add android:exported="true"
to all receivers declared in the manifest.
<receiver android:name=".alarms.AlarmReScheduler"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<!-- For HTC devices -->
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
Also for Activities (the one that would be launched by Android OS A.K.A Launcher activity)
<activity
android:name=".main.SplashScreen"
android:exported="true"
android:theme="@style/FullscreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Note: For Services and Broadcast Receivers that use intent filters, you must explicitly declare the android: exported
attribute.
Don't just add android:exported="true"
to just everything. Cases where the Broadcast receivers need to be visible to Android OS, are examples where where you might want to specify android:exported
. The Intent filters in that code mean I wanted Android OS to wake up my Android app and perform an operation.
android.intent.action.BOOT_COMPLETED
is a very good example because Android OS sends broadcasts to every application installed in the device. So technically, it would mean that any Broadcast receiver that has an intent filter with actions should always declare android:exported="true"
.
AndroidManifest.xml
have every component with an<intent-filter>
explicitly have theandroid:exported
attribute set? Please include your entireAndroidManifest.xml
. – Wrecker./gradlew processDebugAndroidTestManifest --debug
, by typing the aforementioned command into the android studio built-in terminal. Scrolling up in the log let me find the culprit. For me, it was espresso-contrib and espresso-core. Pressingctrl+alt+shift+s
, selecting Dependencies, and then selecting the highest available version (which at the time of this, was 3.5.0-alpha03), resolved the problem after following up with Apply and Ok. – Guyenne