sakshya73
sakshya73

Reputation: 7162

android:exported needs to be explicitly specified for <service>

I am getting this error when I am upgrading my react-native version from 0.66.2 to 0.68.2.

Error

Manifest merger failed : android:exported needs to be explicitly specified for . 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.

Upvotes: 1

Views: 2131

Answers (2)

jkim
jkim

Reputation: 119

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.

enter image description here

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!

Upvotes: 1

sakshya73
sakshya73

Reputation: 7162

In the latest version of Android, we need to explicitly define the value for android:exported for all the service and activity in AndroidManifest.xml file.

For example:

 <service android:exported="false" android:name="serviceName" />

Upvotes: 2

Related Questions