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”.
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.
aherrick
http://twitter.com/andrew_herrick http://andrewherrick.com Run, code, slick.
Updated on June 27, 2022Comments
-
aherrick about 2 years
I have a basic Xamarin Forms app I created. It works fine against the iOS simulator.
However when I try and run with a VS Android Emulator (5.1in Marshmallow) it crashes every time upon opening. Even when I try and run without debugging. Below is the error I keep seeing:
01-14 16:22:10.290 D/Mono ( 1366): AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/App3.Droid-2/libaot-mscorlib.dll.so" not found 01-14 16:22:10.290 D/Mono ( 1366): AOT module '/Users/builder/data/lanes/2512/d3008455/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/App3.Droid-2/libaot-mscorlib.dll.so" not found 01-14 16:22:10.294 D/Mono ( 1366): Unloading image data-0x9659b010 [0xb93d5940].
I am running VS2015 + Xamarin Forms 2.0 latest and greatest.
What's going on here?
-
Coding with Cookie over 8 yearsAre you able to run your app with another emulator?
-
Tok' over 8 yearsI have the same problem but only in debug mode (release mode and concrete smartphone are working fine). Another message is also written in Xamarin log: "Could not connect to the debugger". Just for reference, there is a thread on Xamarin forum talking about it without any solution for now (forums.xamarin.com/discussion/50696/…)
-
aherrick over 8 yearsThanks TOK. Yeah I'm able to run it with the actual phone so that is sufficient for now
-
-
DilbertDave almost 8 yearsExcellent - option 1 resolved my issue (any app would start and immediately close)
-
Zverev Evgeniy almost 8 years@aherrick Sorry to spoil your comment. I switched the suggested routines so the one that helped you is now number one.
-
Marco Rinaldi over 7 yearsThe first solutions has solved the issue for me! Thanks!!
-
Rast over 7 yearsHow does one have to find out this magic checkbox in Hyper-V Manager? I mean, if i install VS, Xamarin, required Android things, and debugging of the empty sample project fails, normally i have to go there and check this option. What were they thinking?!
-
Zverev Evgeniy over 7 years@Rast It's a matter of analyzing adb log I think. The problem only arises on the newer Intel CPUs. Those who are familiar with the beast named Virtualization and its implementation by Intel for Windows has a chance of guessing such a thing. The problem is that
they
are not thinking becausethey
do not exist. It's a problem somewhere in between Intel and Microsoft. Worst kind of luck. Years can pass before Intel and Microsoft agree on the matter who is going to fix a line or two in their code. -
Admin over 7 yearsTick from me, thanks. Changing the compatibility on Processor worked
-
MirlvsMaximvs over 7 yearsThank you so much, brilliant!
-
vibhu over 6 yearsSaved a lot of time!
-
Zverev Evgeniy over 6 years@vibhu You should really consider moving to the new emulators provided by google (Android Studio for windows). New android APIs (24 and above) will only be available there. Microsoft does not seem to continue supporting their emulator.
-
vibhu over 6 years@Zverev - Thank you so much for this advice