chemerisuk / cordova-plugin-firebase-messaging

Cordova plugin for Firebase Cloud Messaging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add android:exported to intent filter

RTK opened this issue · comments

Error message when trying to build for Android with target SDK 31:

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.

This plugin adds the following intent filter to the manifest:

        <service android:name="by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

Solution:

Add android:exported attribute to the service

        <service android:name="by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService" android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

@RTK You fix this at your side till the owner of this repo updates it by adding the below code to your config.xml's android tag

<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application/service[@android:name='by.chemerisuk.cordova.firebase.FirebaseMessagingPluginService']" mode="merge">
    <service android:exported="true"/>
</edit-config>

It will add android:exported to the service in the AndroidManifest.xml.

when i re-run

ionic cordova build android

Element service#org.apache.cordova.firebase.FirebasePluginMessagingService duplicated with element declared at AndroidManifest.xml

when i re-run

ionic cordova build android

Element service#org.apache.cordova.firebase.FirebasePluginMessagingService duplicated with element declared at AndroidManifest.xml

I've got the same issue..

@bjornmassoels i've solve it by adding android.exported = false or true to android.json file like this

{
              "xml": "<service android:exported=\"false\" android:name=\"org.apache.cordova.firebase.FirebasePluginMessagingService\"><intent-filter><action android:name=\"com.google.firebase.MESSAGING_EVENT\" /></intent-filter></service>",
              "count": 1
            },

then hit ionic cordova build android

Which android.json are you adding this too?