1

I am just getting into xamarin android development for the purposes of a project for work and for personal gain and I am running into issues with debugging. The project I have is just an android blank app project. I added 2 Buttons and a TextView called buttonPrev, buttonNext and textTitle. Clicking the previous button sets the textTitle text to "Prev Clicked" and the next button changes the textTitle to "Next Clicked". In the buttonPrev_Click event handler I set a break point. This break point turns to a disabled break point as soon as I run the application in the android emulator.

The problem I currently have is that when I set a break point, the break point icon to the left of the code is a disabled break point. When hovering the mouse over the disabled break point that is not being hit, this message below is what I get.

The break point will not currently be hit. Module containing this break point has not yet loaded or the break point address could not be obtained. Location: MainActivity.cs line 36 character 10 ('CoursesAndroid.MainActivity._buttonPrev_Click(object sender, EventArgs e)')

Things I have tried by using research on the internet.

  1. Making sure that the Use Shared Runtime checkbox is checked in the project properties.
    Location: Project Properties=>Android Options=>Packaging Tab=> Use Shared Runtimes.
  2. Checking & unchecking the Use Fast Deployment(debug mode only) checkbox. Project Location: Properties=>Android Options=>Packaging Tab=>Use Fast Deployment(debug mode only)
  3. Setting the debugger option to both Xamarin(default) & Microsoft. Location: Properties=>Android Options=>Packaging Tab=>Debugger
  4. Deleting the obj & bin directories in the project directory and rebuilding and running the application.
  5. Uninstalling and Reinstalling Hyper-V in addition to removing all hidden items in the device manager before re-installation.

I am at a loss here any any help would greatly be appreciated. If additional information is needed, don't hesitate to ask and I will do my best to answer them.

Things I am using:

  1. Visual Studio 2015 Update 3 - Version 14.0.25425.01
  2. Android SDK - Android 7.0 (API 24)
  3. Visual Studio Emulator For Android
  4. Emulator Device Profile: 5" KitKat (4.4) XXHDPI Phone API Level 19 (KitKat, 4.4)

Project Properties Setup:

NOTE: These are settings in the Android Options section.

Packaging Tab

  1. Use Shared Runtime: Checked
  2. Use Fast Deployment (debug mode only): Checked
  3. Generate one package(.apk) per selected ABI: Unchecked(default)
  4. Enable Multi-Dex: Unchecked(default)
  5. Enable Progaurd: Unchecked & Disabled (cant use & default)
  6. Enable developer instrumentation(debugging and profiling): Checked(default)
  7. Debugger: Set to Microsoft (default was set to Xamarin)

Linker Tab

  1. Linking: None(default)
  2. Skip linking assemblies: blank(default)
  3. Additional supported encodings: All Unchecked(default)

Advanced Tab

  1. Supported architectures: All Checked(default)
  2. Java Max Heap Size: empty(default)
  3. Additional Java Options: empty(default)
  4. Additional mondroid arguments: empty(default)

Additional Information Found - 9/01/2016

This post Using Microsoft debugger with Xamarin Android that was related to this post had information about the difference between using the Microsoft and Xamarin debuggers. The Microsoft debugger is for native applications and the Xamarin debugger is for managed applications. The behavior is slightly different using the Microsoft debugger then the Xamarin one. With the Xamarin debugger, the breakpoint does not disable itself but still does not get hit where the Microsoft debugger disables itself and does not get hit. That makes sense to me so I am keeping the setting on Xamarin for the debugger. I also noticed that when using the Xamarin debugger, the attached process item in the Debug Location Toolbar is empty and I am not even in debug mode and the application is not running. So the problem is that it cannot attach to the debugger. Below is additional information from the output window that is set to Debug in visual studio when running the application. The lines highlighted in bold I think probably the issue due to the assembly not being found.

Debug Output Window Info

Android application is debugging. Could not connect to the debugger. 09-01 10:22:50.172 D/Mono ( 2431): Config attempting to parse: '/Users/builder/data/lanes/3540/1cf254db/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/mscorlib/mscorlib.config'.09-01 10:40:57.644 W/monodroid( 2796): Trying to load sgen from: /data/data/CoursesAndroid.CoursesAndroid/files/.override/links/libmonosgen-2.0.so

09-01 10:40:56.532 D/dalvikvm( 2763): Late-enabling CheckJNI

09-01 10:40:56.564 D/dalvikvm( 2763): Trying to load lib /data/app-lib/CoursesAndroid.CoursesAndroid-2/libmonodroid.so 0xa9037000

09-01 10:40:56.564 D/dalvikvm( 2763): Added shared lib /data/app-lib/CoursesAndroid.CoursesAndroid-2/libmonodroid.so 0xa9037000

09-01 10:40:56.564 W/monodroid( 2763): Using override path: /data/data/CoursesAndroid.CoursesAndroid/files/.override

09-01 10:40:56.568 W/monodroid( 2763): Using override path: /storage/emulated/0/Android/data/CoursesAndroid.CoursesAndroid/files/.override

09-01 10:40:56.572 W/monodroid( 2763): Trying to load sgen from: /data/data/CoursesAndroid.CoursesAndroid/files/.override/libmonosgen-2.0.so

09-01 10:40:56.572 W/monodroid( 2763): Trying to load sgen from: /storage/emulated/0/Android/data/CoursesAndroid.CoursesAndroid/files/.override/libmonosgen-2.0.so

09-01 10:40:56.572 W/monodroid( 2763): Trying to load sgen from: /data/app-lib/CoursesAndroid.CoursesAndroid-2/libmonosgen-2.0.so

09-01 10:40:56.572 W/monodroid( 2763): Trying to load sgen from: /data/data/CoursesAndroid.CoursesAndroid/files/.override/links/libmonosgen-2.0.so

09-01 10:40:56.572 W/monodroid-debug( 2763): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8963,server=y,embedding=1

09-01 10:40:56.736 W/monodroid-debug( 2763): Accepted stdout connection: 43

09-01 10:40:57.496 D/Mono ( 2763): Image addref mscorlib[0xb92dafe0] -> mscorlib.dll[0xb92da2a0]: 1

09-01 10:40:57.500 D/Mono ( 2763): AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/CoursesAndroid.CoursesAndroid-2/libaot-mscorlib.dll.so" not found

09-01 10:40:57.500 D/Mono ( 2763): AOT module '/Users/builder/data/lanes/3540/1cf254db/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/CoursesAndroid.CoursesAndroid-2/libaot-mscorlib.dll.so" not found

09-01 10:40:57.500 D/Mono ( 2763): Config attempting to parse: 'mscorlib.dll.config'.

09-01 10:40:57.500 D/Mono ( 2763): Config attempting to parse: '/Users/builder/data/lanes/3540/1cf254db/source/monodroid/builds/install/mono-x86/etc/mono/assemblies/mscorlib/mscorlib.config'.

09-01 10:40:57.512 D/Mono ( 2763): Assembly mscorlib[0xb92dafe0] added to domain RootDomain, ref_count=1

Community
  • 1
  • 1

3 Answers3

6

After more digging around, I have found the answer to my own question. Here is how I fixed the issues.

Here is the post that has information about the fix.

Xamarin Forms Android App Crashes Running Debug with VS Android Emulator

The Visual Studio Emulator For Android uses a virtual machine in Hyper-V. The problem is that when the virtual machines are created, a processor setting is not properly set for the purpose of debugging. So to fix the issue, a setting for the virtual machine's processor has to be set to allow the debugging to occur.

Also make sure that the following project properties are set.

  1. Project Properties => Android Options => Use Fast Deployement(debug mode only) is unchecked
  2. Project Properties => Android Options => Debugger is set to Xamarin

I hope that this post helps out anybody that is having issues with debugging.

HAPPY CODING!!

Community
  • 1
  • 1
  • Since you have resolved this issue, please feel free to mark it as the answer, so it would be helpful for other community members who meet the same issue. – Jack Zhai Sep 02 '16 at 02:34
  • It will not let me yet. It says I can mark it as answered in 24 minutes. – Calvin Wilkinson Sep 03 '16 at 12:25
  • The "Fast Deployment" was my issue. Wish I could upvote this 10 more times, I've gone 2 weeks of saying "screw Android" in our Xamarin Forms project, but no more! – Jangles May 26 '17 at 16:50
  • amazing... unchecking the fast deployment thing made it work... thanks – Ahmed Elashker Jul 10 '17 at 07:43
0

Your post did help with a similar issue with debugging I was experiencing. See details of the issue I had http://forums.xamarin.com/discussion/comment/223723

WXM1967
  • 137
  • 1
  • 7
-1

I just ckecked the csproj file (Visual Studio). There was a wrong platform definition:

PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "

PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "

And in the Xamarin project properties: x86

I chenge AnyCPU to x86 in the csproj file. Now it's working for me.

And the old workaround does not work for me.

looks like a bug of xamarin

WebDev
  • 11
  • 4