Home > Software engineering >  Error when debugging Xamarin Project on Android Exception: "Default constructor not found for t
Error when debugging Xamarin Project on Android Exception: "Default constructor not found for t

Time:11-23

Im getting an error when trying to Debug/Deploy my App (that works on UWP) to Android. I have tried to run the App on the emulator in VS (Android 9) and my smartphone (Android12).

The error i am getting is "Default constructor not found on type [MyApp].Views.AboutPage".

The AboutPage class:

public partial class AboutPage : ContentPage
      {
         public AboutPage()
         {
             InitializeComponent();
             BindingContext = new AboutViewModel();
         }
     }

As in this class, I do not have any non default constructors in my entire Application.

I have already tried to set the linker setting to "Sdk Assemblies only", which resulted in a different error. When trying to debug a Microsoft-Default project on my smartphone it worked with the same settings as in my app. The contents of the AboutPage class do not differ between these two projects.

CodePudding user response:

This is a common problem. You can first try to delete the bin folders and the obj folders and rebuild it. If it doesn’t work, try to restart the visual studio.

If the problem persists, you can try to recheck if there are some problems in your code.

CodePudding user response:

The exception was caused by a DependencyService, removed it and it worked.

  • Related