Search code examples
androidandroid-emulator.net-6.0mauiwindows-11

Unable to run .NET MAUI project in windows 11 pro virtual machine


I'm trying to run my first .net maui project. I have my Windows 11 pro virtual machine running on Windows 11 Home host.

I have the pre-requisites configured.

  1. Installed VS 2022 17.3.0.
  2. Installed .Net Multi-platform App UI Development.

enter image description here

  1. Enabled Hyper-V in windows features.

enter image description here

  1. Run VS 2022 as Administrator.
  2. Create .Net Maui Default App.
  3. Run via Android Pixel 5 - API 31 (Android 12.0 - API 31) emulator.
  4. Deploy failed Emulator cannot be started.

enter image description here

Output:

Build started...
Starting emulator pixel_5_-_api_31 ...
1>------ Build started: Project: MauiApp1, Configuration: Debug Any CPU ------
C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -netfast -avd pixel_5_-_api_31 -prop monodroid.avdname=pixel_5_-_api_31
Emulator pixel_5_-_api_31 cannot be started.
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>MauiApp1 -> C:\Users\Abdul Rahman\source\repos\MauiApp1\MauiApp1\bin\Debug\net6.0-android\MauiApp1.dll
2>------ Deploy started: Project: MauiApp1, Configuration: Debug Any CPU ------
2>Starting deployment to pixel_5_-_api_31 ...
2>Starting emulator pixel_5_-_api_31 ...
2>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -netfast -avd pixel_5_-_api_31 -prop monodroid.avdname=pixel_5_-_api_31
2>Emulator pixel_5_-_api_31 cannot be started.
2>Deploy failed
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

Please assist on what I'm missing.


Solution

  • Jason thanks for your inputs. Here is how I solved using a physical android device.

    Steps:

    1. Enable Developer Options in your Mobile device
    2. Enable USB debugging in your Mobile device

    enter image description here

    1. Connect your device to your virtual machine. A popup titled Allow USB Debugging? appers in phone. Allow it.

    enter image description here

    1. Open MAUI project
    2. From the Project run dropdown select Android Local Devices and select your device.

    enter image description here

    1. Now run the app.
    2. It will be deployed in your device and open in your device.
    3. A preview will appear in XAML Live Preview window inside visual studio.

    enter image description here