question

ASH-1598 avatar image
0 Votes"
ASH-1598 asked JarvanZhang-MSFT commented

Error when changing the style to dark from the system

Hi guys

I have an Error when changing the style to dark from the system

error in MainActivity.cs
base.OnCreate(savedInstanceState);

error text:
System.NotSupportedException: 'Unable to find the default constructor on type Xamarin.Forms.Platform.Android.ShellItemRenderer.Please provide the missing constructor.'



   protected override void OnCreate(Bundle savedInstanceState)
         {
    
             CrossFingerprint.SetCurrentActivityResolver(() => this);
    
             TabLayoutResource = Resource.Layout.Tabbar;
             ToolbarResource = Resource.Layout.Toolbar;
    
             base.OnCreate(savedInstanceState); **// in this line**

             Window.DecorView.LayoutDirection = LayoutDirection.Rtl;
    
             Xamarin.Essentials.Platform.Init(this, savedInstanceState);
             ZXing.Net.Mobile.Forms.Android.Platform.Init();
    
             global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
             Xamarin.FormsGoogleMaps.Init(this, savedInstanceState);
    
             LoadApplication(new App());
         }

dotnet-xamarin
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have an Error when changing the style to dark from the system

Hi, ASH-1598. Do you mean changing the device to dark theme? That doesn't effect the code. I created a basic shell application to test the function, it works as expected. Try to clean the bin and object folders of both the shared project and platform project. Then rebuild the solution to check if it would work. What's the version of Xamarin.Forms? Please update the package to the lastest stable version.

If the above doesn't work, please try to create a blank shell project to test the function. It seems you use some third-party nugets which may cause the problem.

0 Votes 0 ·

Hi, @ASH-1598
Do you still meet the overlap issue? If so, could you please share more detailed information, I am looking forward to seeing your message.

0 Votes 0 ·

0 Answers