If you setting android:exported but it doesn't work, when you open AndroidManifest.xml in Android Studio, you will see a tab called Merged Manifest. If you click the tab, the error contents are displayed.

error message for example
Merging Errors: Error: android:exported needs to be explicitly specified for element <receiver#androidx.media.session.MediaButtonReceiver>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
In my case, it was difficult because this error was displayed, but when I additionally inserted the code below in the AndroidManifest.xml file, the error disappeared.
...
<receiver android:name="androidx.media.session.MediaButtonReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
...
https://developer.android.com/reference/androidx/media/session/MediaButtonReceiver
Hope this helps you!