Xamarin.Forms and Android 12 Exported=True

Barry Theunissen 1 Reputation point
2022-03-14T19:06:39.533+00:00

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?

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

2 answers

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 72,251 Reputation points Microsoft Vendor
    2022-03-15T01:43:20.987+00:00

    Hello,​

    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
    2022-03-15T16:51:48.513+00:00

    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... ;)