Search code examples
androidxamarinandroid-emulatorvisual-studio-2015visual-studio-emulator

Visual Studio Emulator for Android is not working: mscorlib.dll.so not found


After I configured Hyper-V and managed to get it running, the Visual Studio Emulator for Android is starting up. I can see my splash screen, but then the app is exited. This is the output log:

InspectorDebugSession(1): StateChange: Start -> EntryPointBreakpointRegistered
InspectorDebugSession(1): Constructed
Android application is debugging.
03-25 10:24:48.717 D/dalvikvm( 1251): Late-enabling CheckJNI
03-25 10:24:48.749 D/dalvikvm( 1251): Trying to load lib /data/app-lib/MyApp.Droid-1/libmonodroid.so 0xa8f89c78
03-25 10:24:48.749 D/dalvikvm( 1251): Added shared lib /data/app-lib/MyApp.Droid-1/libmonodroid.so 0xa8f89c78
03-25 10:24:48.761 W/monodroid( 1251): Using override path: /data/data/MyApp.Droid/files/.__override__
03-25 10:24:48.761 W/monodroid( 1251): Using override path: /storage/emulated/0/Android/data/MyApp.Droid/files/.__override__
03-25 10:24:48.761 W/monodroid( 1251): Trying to load sgen from: /data/data/MyApp.Droid/files/.__override__/libmonosgen-2.0.so
03-25 10:24:48.761 W/monodroid( 1251): Trying to load sgen from: /storage/emulated/0/Android/data/MyApp.Droid/files/.__override__/libmonosgen-2.0.so
03-25 10:24:48.761 W/monodroid( 1251): Trying to load sgen from: /data/app-lib/MyApp.Droid-1/libmonosgen-2.0.so
03-25 10:24:48.761 W/monodroid( 1251): Trying to load sgen from: /data/data/MyApp.Droid/files/.__override__/links/libmonosgen-2.0.so
03-25 10:24:48.761 W/monodroid-debug( 1251): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8915,server=y,embedding=1
03-25 10:24:48.917 W/monodroid-debug( 1251): Accepted stdout connection: 43
03-25 10:24:49.693 D/Mono    ( 1251): Image addref mscorlib[0xb948bb30] -> mscorlib.dll[0xb948b0f0]: 1
03-25 10:24:49.697 D/Mono    ( 1251): AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/MyApp.Droid-1/libaot-mscorlib.dll.so" not found
03-25 10:24:49.697 D/Mono    ( 1251): AOT module '/Users/builder/data/lanes/2970/46c3f7e0/source/monodroid/builds/install/mono-x86/lib/mono/aot-cache/x86/mscorlib.dll.so' not found: dlopen failed: library "/data/app-lib/MyApp.Droid-1/libaot-mscorlib.dll.so" not found
03-25 10:24:49.705 D/Mono    ( 1251): Unloading image data-0x95e99010 [0xb948bb90].
Could not connect to the debugger.
InspectorDebugSession(1): HandleTargetEvent: TargetExited
InspectorDebugSession(1): Disposed

I tried to uninstall the data (app, mono, xamarin) in the emulator, restarted Visual Studio/emulator, but nothing of it helped. Why is it such a pain when using an Android simulator? Don't know how Android apps are developed if none of the simulators can't be used in "production".

I should mention that it works on the device and in other simulators like Xamarin Android Player, simulator from Android SDK, ...


Solution

  • Give this a try: Xamarin Forms Android App Crashes Running Debug with VS Android Emulator

    In short:

    1. "Could not connect to the debugger" issue:

    1. Start the Hyper-V manager
    2. Select the emulator you are trying to use
    3. Right-click, hit settings
    4. Click processor
    5. Click Compatibility
    6. Set checkbox “Migrate to a physical computer with a different processor version”

    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”.