Xamarin.Forms and Android 12 Exported=True

Barry Theunissen 1 Reputation point

When I build my project, why is the StartActivity being forced to exported=true in the AndroidManifest, even if I decorate the StartActivity with :

[Activity(Icon = "@mipmap/icon",
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
ScreenOrientation = ScreenOrientation.Portrait,
Exported = false)]

where I have have used Exported=false as you can see above.

If I try to build my solution I get a "duplicate attribute" error, so it seems impossible to set Exported=False on the StartActivity. NONE of my other activities (there is only one
other one : MainActivity) have the Exported=false set.

It is critical that this is done for Android 11, otherwise your app is NOT deployable to the Google Playstore.

I'm running the latest VS2019...no updates outstanding.

Anybody got a solution?

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

2 answers

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 69,466 Reputation points Microsoft Vendor


    This issue is reported in the GitHub, please see this thread: After update cannot build Android with error: Xamarin.Android.Common.targets ( System.InvalidOperationException: Duplicate attribute

    And this issue will be fixed in .NET 6 release, but not yet in Xamarin.Android. If you still want to rebuild it, you can use these builds.

    Best Regards,

    Leon Lu

    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.

  2. Barry Theunissen 1 Reputation point

    I found the culprit! I was using the Microsoft.AppCentre.Distribute SDK...a big no-no...even though I augmented it with the Google Play version which Microsoft came out with to solve this issue...Google Play still does not like it...I turfed it...let's see what happens now in the Google Play review...holding thumbs... ;)