[英]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
.当我将 react-native 版本从
0.66.2
升级到0.68.2
时,出现此错误。
Error错误
Manifest merger failed: android:exported needs to be explicitly specified for.
清单合并失败:android:exported 需要明确指定。 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.当相应组件定义了意图过滤器时,需要针对 Android 12 及更高版本的应用程序为
android:exported
指定显式值。 See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported 。
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.在最新版本的 Android 中,我们需要为
AndroidManifest.xml
文件中的所有服务和活动显式定义android:exported
的值。
For example:例如:
<service android:exported="false" android:name="serviceName" />
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 .如果您设置 android:exported 但它不起作用,当您在Android Studio中打开
AndroidManifest.xml
时,您将看到一个名为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.就我而言,这很困难,因为显示了此错误,但是当我在
AndroidManifest.xml
文件中另外插入以下代码时,错误消失了。
...
<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 https://developer.android.com/reference/androidx/media/session/MediaButtonReceiver
Hope this helps you!希望这对你有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.