Xamarin Forms Android App Crashes Running Debug with VS Android Emulator
In short:
1. "Could not connect to the debugger" issue (Android app starts and immediately closes, debugging stops):
- Close the Android simulator window to shut down the virtual machine.
- Start the "Hyper-V Manager" (Microsoft program to manage virtual machines in Windows, you have it installed)
- Select the emulator you are trying to use
- Right-click for context menu, hit Settings
- In the settings dialog expand Processor
- Click Compatibility
- In the right pane set checkbox “Migrate to a physical computer with a different processor version”
- Start the debugging in Visual Studio to restart the simulator
2. The missing libaot-mscorlib.dll.so issue:
Go to the properties of the Android project, hit tab “Android options”, and unselect “Use Fast Deployment”.
Source:
Fix for “could not connect to the debugger” while deploying Xamarin Forms apps to the Visual Studio Android Emulator (VS2015)
This issue only seems to be occurring on the newer generation of processors, which explains why I never saw it before.
This happens because of an incompatibility between the Android images for the Visual Studio emulator for Android and the newer generations of Intel processors as of year 2015.
This solution is also published here: Visual studio android emulator will not start fully
UPDATE November 29, 2017
You should really consider moving to the Android emulators provided by Google via Android Studio for Windows. Newer Android API levels (24 and above) are only available there and Microsoft does not seem to care.
Unfortunately, we have no plans to publish Android images past 4.4. We recommend that you try Google or GenyMotion’s emulator for future images of the Android operating system.
How to find the reason for XAMARIN App crash
In VS, try this:
- Go to menu
Debug > Windows > Exception Settings
or typeCtrl-Alt-E
. - Tick the box on the line that says "Common Language Runtime Exceptions".
- Start a Debug session (F5).
- VS will now break on any exception that occurs, even the ones that have a
try...catch
. - You may need to ignore a few exceptions (press F5 to proceed) to get to the actual location of your problem.
- Analyze the problem and write a fix.
- To reset VS back to its normal behavior, right click on the line "Common Language Runtime Exceptions" and select "Restore Defaults".
Xamarin forms, App running on Visual Studio Android Emulator But crashes on real device
Changing Android project options fixed the issue for me.
Open your Android project's Properties. Go to Android Options. Change Linking property to "Sdk Assemblies Only".
Xamarin Forms Android app crashes in Release for few devices
For this error, you could try to reinstall the SDK of Android.
Related Topics
Inflate Layout Programmatically Within Another Layout
After Update of as to 1.0, Getting "Method Id Not in [0, 0Xffff]: 65536" Error in Project
How to Send File from Android Device to Other Device Through Bluetooth by Code
Using Webview Sethttpauthusernamepassword
Android Repeat Action on Pressing and Holding a Button
Android Cardview Remove Padding
How to Add PDFbox to an Android Project or Suggest Alternative
Gradle Flavors for Android with Custom Source Sets - What Should the Gradle Files Look Like
Android: Total Height of Scrollview
Android/Eclipse Panic: Could Not Open
How to Know If a Fragment Is Visible
E/Surface﹕ Getslotfrombufferlocked: Unknown Buffer: 0Xab7519C0