Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I hit the breakpoint when I start debug the Xamarin Android Application?

When I start to debug my first Xamarin Android application, I set some breakpoints. Whatever I do, it will still not hit the breakpoint. What's wrong with this?

I have tried many times, but it did not help.

like image 423
SimpleCoder Avatar asked Oct 19 '22 10:10

SimpleCoder


1 Answers

I've found that the name of the folder that contains your project can make a difference. Do you have any spaces or punctuation characters in yours?

The folder name is often the same as the project name, but it doesn't have to be. I had a Xamarin Android project called "Engagement (Android)" within a solution, and by default it was stored on disk at ...\Engagement (Android)\Engagement (Android).csproj

No matter what I did, it wouldn't hit breakpoints. Brand new projects that I added (called Test1, Test2, etc) - debugged perfectly.

When I changed the folder name to "Engagement_Android" (keeping the same project name) - it started hitting breakpoints again.

Other symptoms that went with this included the "Clean Project" option not clearing all the files from the bin/debug folder (it left behind the project's main DLL and PDB file).

The thing that nailed it for me was noticing that when I did a clean build, the bin/debug folder did not contain an "MDB" file for the main exe (in this case Engagement Android.dll.mdb) and so was not been packaged into APK file.

It turns out that the MDB files are the way that debugging information gets packaged up into the APK - without it you can't debug! I think they are created by a tool called PDB2MDB.exe during the build process.

If you try this, bear in mind it is the physical folder name not the project name that is important. Also, you need to edit the SLN file because it contains a reference to the path of each project in the solution - so make the change there too.

like image 61
Andy Burgess Avatar answered Nov 15 '22 07:11

Andy Burgess