android:exported : <接收 com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceive

Abb*_*ani 0 reactjs react-native react-native-push-notification

任务“:app:processReleaseMainManifest”执行失败。

清单合并失败:需要为元素 <receiver#com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver> 显式指定android:exported 。android:exported当相应组件定义了意图过滤器时,面向 Android 12 及更高版本的应用需要指定显式值。

AndroidManifesr.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.projectrn">

<uses-permission android:name="android.permission.INTERNET" />
<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:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
   <!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                android:value="false"/>
    <!-- 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.RNPushNotificationActions" android:exported="false"/>
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
    <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
        <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"/>
        </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>
Run Code Online (Sandbox Code Playgroud)

Shi*_*har 5

您需要在标签中添加android:exported= true 或 false 。根据Android 文档<receiver>com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver

如果activityservicebroadcast receiver使用意图过滤器并且没有显式声明 的值android:exported,则您的应用无法安装在运行 Android 12 或更高版本的设备上。