上传Android App Bundle至Google Play时遇android:exported属性合规问题
解决Google Play上传Android App Bundle的android:exported属性错误
问题详情
上传Android App Bundle到Google Play时,收到错误提示:
您上传的APK或Android App Bundle中存在带有intent filter的activity、activity alias、service或broadcast receiver未设置android:exported属性,该文件无法在Android 12及更高版本安装。
已手动为自身Manifest中所有带intent filter的组件添加android:exported="true",且检查了node modules的AndroidManifest文件,但错误仍存在。提供的Manifest文件如下:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.dummy"> <uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" /> <!-- < Only if you're using GCM or localNotificationSchedule() > --> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:usesCleartextTraffic="true" android:allowBackup="false" android:theme="@style/AppTheme"> <!-- <activity android:name=".SplashActivity" android:theme="@style/SplashTheme" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> --> <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="stateAlwaysHidden|adjustPan|adjustResize" android:screenOrientation="portrait" android:launchMode="singleTop" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/> </intent-filter> </activity> <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" android:value="YOUR NOTIFICATION CHANNEL NAME"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description" android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/> <!-- Change the value to true to enable pop-up for in foreground (remote-only, for local use ignoreInForeground) --> <meta-data android:name="com.dieam.reactnativepushnotification.notification_foreground" android:value="true"/> <!-- Change the resource name to your App's accent color - or any other color you want --> <meta-data android:name="com.dieam.reactnativepushnotification.notification_color" android:resource="@color/white"/> <!-- or @android:color/{name} to use a standard color --> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" /> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver" android:exported="true"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <!-- <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false" > <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> --> <receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/> <receiver android:enabled="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver" android:exported="true"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.QUICKBOOT_POWERON"/> <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> <receiver android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionReceiver" android:exported="true"> <intent-filter> <action android:name="io.invertase.firebase.notifications.BackgroundAction"/> </intent-filter> </receiver> <service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService"/> <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService" android:exported="true"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService"/> </application> <queries> <intent> <action android:name="com.google.android.youtube.api.service.START"/> </intent> <intent> <action android:name="android.intent.action.VIEW" /> <data android:scheme="http" /> </intent> <intent> <action android:name="android.intent.action.VIEW" /> <data android:scheme="https" /> </intent> </queries> </manifest>
解决步骤
1. 生成并检查合并后的Manifest文件
Android会自动合并自身Manifest与所有依赖库的Manifest,问题大概率出在合并后的文件中:
- 打开Android Studio,点击菜单栏
Build > Analyze APK - 选择生成的App Bundle(.aab)或APK文件
- 在弹窗中找到
AndroidManifest.xml,查看完整的合并配置 - 重点排查所有带
<intent-filter>的<activity>、<receiver>、<service>标签,确认每个都添加了android:exported属性
2. 手动覆盖依赖库中缺失属性的组件
根据合并后的Manifest结果,在自身AndroidManifest.xml中补充对应组件的android:exported属性:
从当前提供的Manifest来看,以下组件可能存在问题:
<!-- 补充RNPushNotificationPublisher的exported属性 --> <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" android:exported="false" /> <!-- 补充RNFirebaseNotificationReceiver的exported属性 --> <receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver" android:exported="false" /> <!-- 补充RNFirebaseBackgroundNotificationActionsService的exported属性 --> <service android:name="io.invertase.firebase.notifications.RNFirebaseBackgroundNotificationActionsService" android:exported="false" /> <!-- 补充RNFirebaseBackgroundMessagingService的exported属性 --> <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" android:exported="false" />
3. 确认android:exported值的正确性
- 组件需要接收外部应用/系统的Intent(比如Launcher Activity、系统广播接收器)时,设置
android:exported="true" - 仅内部使用的组件,设置
android:exported="false"即可
4. 重新构建并验证
修改完成后重新生成App Bundle,再次通过Analyze APK工具检查合并后的Manifest,确认所有带intent filter的组件都已添加android:exported属性,再尝试上传到Google Play。
内容的提问来源于stack exchange,提问作者Dinesh Lt
相关产品推荐
相关产品推荐

