Getting android:exported needs to be explicitly specified for element even after adding the android:exported value

Sreejith Sreenivasan 851 Reputation points
2023-10-27T05:51:23.2033333+00:00

I am getting below errors on my Xamarin Forms android project when updating the target version to 33.

Severity Code Description Project File Line Suppression State Error android:exported needs to be explicitly specified for element <service#crc6494e14b9856016c30.PNFirebaseIIDService>. 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. MyProject.Android \obj\Debug\110\AndroidManifest.xml 61

Severity Code Description Project File Line Suppression State Error android:exported needs to be explicitly specified for element <service#crc6494e14b9856016c30.PNFirebaseMessagingService>. 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. MyProject.Android \obj\Debug\110\AndroidManifest.xml 66

I am getting below errors on my Xamarin Forms android project when updating the target version to 33.

Severity Code Description Project File Line Suppression State Error android:exported needs to be explicitly specified for element <service#crc6494e14b9856016c30.PNFirebaseIIDService>. 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. MyProject.Android \obj\Debug\110\AndroidManifest.xml 61

Severity Code Description Project File Line Suppression State Error android:exported needs to be explicitly specified for element <service#crc6494e14b9856016c30.PNFirebaseMessagingService>. 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. MyProject.Android \obj\Debug\110\AndroidManifest.xml 66

I have added android:exported values on Manifest and MainActivity files and close the project and did clean and rebuild.

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.5" package="com.companyname.appname" android:installLocation="auto" android:versionCode="16">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application android:label="appname" android:usesCleartextTraffic="true" android:allowBackup="false" android:icon="@drawable/logo" android:requestLegacyExternalStorage="true">
        <activity android:icon="@drawable/icon" android:name=".MainActivity" android:label="SmartWCM" android:exported="true">
            <intent-filter>
                <data android:scheme="https" android:host="www.smartwcm.com" android:pathPrefix="/domain" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
            <intent-filter>
                <data android:scheme="http" android:host="www.smartwcm.com" android:pathPrefix="/domain" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.companyname.appname.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
        </provider>
        <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
        <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

I have added exported value on activity, provider, FirebaseInstanceIdInternalReceiver and FirebaseInstanceIdReceiver.

MainActivity

[Service(Exported = true)]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
public class FirebaseNotificationService : FirebaseMessagingService
{

}

[Service(Exported = true)]
[IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
public class FirebaseRegistrationService : FirebaseInstanceIdService
{

}

Added the same on FirebaseRegistrationService and FirebaseNotificationService under MainActivity.

But the error shows add it on PNFirebaseIIDService and PNFirebaseMessagingService. But these properties are not added on my project.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 39,391 Reputation points Microsoft Vendor
    2023-10-30T02:39:12.57+00:00

    Hello,

    Upon investigation, PNFirebaseIIDService and PNFirebaseMessagingService are the classes in Plugin.FirebaseCloudMessaging. This plugin has not been updated since 2020, therefore, it is not compatible with higher versions of Android.

    Please refer to and Remote Notifications with Firebase Cloud Messaging, and use Xamarin.Firebase.Messaging as an alternative.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful