sina
sina

Reputation: 139

Breakpoints is not hitting while debugging a .NET MAUI android application

I have been working on a MAUI android application and when debugging, the breakpoints is not hitting and the application enter in a break state. But for windows app it works well. I think this is an issue with the .NET 6 Android Tooling in visual studio 2022. Is there any solutions for this problem ?

Upvotes: 5

Views: 4402

Answers (3)

MarchalPT
MarchalPT

Reputation: 1576

I had the same problem and it is now working, try this:

  1. Windows -> Settings -> Update & Security -> For Developers -> Developer Mode - On enter image description here

  2. Solution Properties -> Deploy - On enter image description here

  3. Visual Studio -> Tools -> Options -> Xml Hot Reaload -> Disable all enter image description here

  1. The you can just set your project has startup and run it.

Upvotes: 1

mkdave99
mkdave99

Reputation: 905

I was also having problems debugging some projects. (Preview 17.1.0) The ones that were failing had the following project settings.

<PropertyGroup>
    <TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks> ...

Moving Android first fixed my problem

<PropertyGroup>
    <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> ...

Upvotes: 1

michael g
michael g

Reputation: 641

Here is a few steps I did to make things work with debugging MAUI Android apps. I was able to debug and get my regular exceptions and hit breakpoints after this.

  1. Add this code to Android platform main activity OnCreate method

    AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

Then this hander method in the same class

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ System.Diagnostics.Debug.WriteLine(e.ToString());}
  1. Reset Your Exceptions for CLR. Shortcut is (Ctrl+Alt+E).

    Just double-click on the CLR Exceptions checkbox to reset.

enter image description here

  1. Disable Debug Your Code Only in Options

enter image description here

Upvotes: 3

Related Questions