Android 12中Xamarin Forms的Intercom无法工作,需配置android:exported属性
Android 12(API31+)下Xamarin Forms集成Intercom的FCM报错解决
问题
运行时触发报错:
io.intercom.android.sdk.fcm.IntercomFcmMessengerService: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present
原因是Android 12及以上版本强制要求:所有带有intent filter的组件(服务、广播接收器等)必须显式声明android:exported属性,而Intercom自带的FCM消息服务默认未配置该属性,触发系统校验报错。
解决步骤
在Xamarin Forms Android项目的AndroidManifest.xml中添加以下配置,覆盖Intercom的FCM服务声明:
<service android:name="io.intercom.android.sdk.fcm.IntercomFcmMessengerService" android:exported="true"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
关键说明
android:name必须指定为io.intercom.android.sdk.fcm.IntercomFcmMessengerService,这是Intercom内部FCM服务的完整类名,只有这样才能覆盖它默认未配置exported的声明。android:exported设为true是因为该服务需要接收Firebase的外部消息事件,必须允许外部系统(Firebase)启动它,设为false会导致Intercom推送消息无法正常接收。
额外提醒
- 确认你的Android项目目标SDK已设置为Android 12(API31)或更高版本。
- 如果项目中还有自定义的Firebase消息服务,也要确保它同样显式声明了
android:exported属性,避免同类报错。
内容的提问来源于stack exchange,提问作者Kamel
相关产品推荐
相关产品推荐

