[FIXED] Xamarin.Android without the 'android:exported' property set error


When Xamarin.Android is set to Android 12, I received

"You uploaded an APK or Android App Bundle which has an activity,
activity alias, service or broadcast receiver with intent filter, but
without the ‘android:exported’ property set. This file can’t be
installed on Android 12 or higher. See:

error while uploading the APK to the Google Play Console for new release.

I have added the the Exported attribute to my activities and services, yet still setting this error.

[Activity(Label = "@string/AppDrawerName", Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_launcher_round", Theme = "@style/MainTheme", MainLauncher = true, Exported = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Portrait)]

    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity


[Service(Exported = true)]
    public class BarcodeService : IBarcodeService

From the compile output I can see the message below

Namespace ‘com.google.android.gms.stats’ used in: AndroidManifest.xml,

android:exported needs to be explicitly specified for element
<service#crc640921eac73192168e.PNMessagingService>. 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
for details.

Then I go into the "obj/Debug" folder to open the Manifest, I can see the below service is auto generated

<service android:name="crc640921eac73192168e.PNMessagingService">
        <action android:name="com.google.firebase.MESSAGING_EVENT" />

Anybody know how can I set [Service(Exported = true)] for this service since it’s auto generated?


After got the info from the "obj/Debug" AndroidManifest.xml of the below

I added it into my project’s Manifest manually under the tag, finally it’s working. Please see below for the Manifest in project.

<application android:label="XXXXX">
    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
    <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/super_red" />
    <service android:name="crc640921eac73192168e.PNMessagingService" android:exported="false">
            <action android:name="com.google.firebase.MESSAGING_EVENT" />

It’s good to check the Manifest on the obj/ folder to ensure all has exported set in the parent.

Answered By – TPG

Answer Checked By – Candace Johnson (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published