Search code examples
mauivisual-studio-mac.net-8.0

.NET MAUI Android Emulator Cannot Execute dll Visual Studio Mac


I am running Visual Studio on a Mac for .NET MAUI. I was playing around with some package versions following a Visual Studio update about a week ago, and now when I try to run my project on the Android Emulator, I get a message that says Cannot execute "[my directory path]/bin/Debug/net7.0-android/[my project name].dll. The project still runs on the iOS Simulator without issue.

Visual Studio Error Message

When I open Project Properties, I see the Android Target is now missing. It was previously shown on this screen.

Project Properties

I think this started when I tried to change the Target .NET Runtime to .NET 8.0 for Android before I had .NET 8.0 installed. The Deploying to Device output appears to be normal, although I admit I don't usually pay much attention to it and probably wouldn't recognize an anomaly.

Deploying to Device output

I have attempted the following and none seemed to solve the problem:

  1. Restart Visual Studio
  2. Restart Android Emulator
  3. Restart Computer
  4. Install new additional Android Device in Android Device Manager

Solution

  • I was able to solve my problem by following steps outlined in this video: https://www.youtube.com/watch?v=3lZldOqg5i0&t=525s

    Before making any changes, when I ran dotnet workload search in a Terminal window, I got this result which is missing maui-android.

    Terminal Output before changes

    So I ran sudo dotnet workload install maui and sudo dotnet workload install maui-android and now I have this list:

    Terminal Output after changes

    I restarted Visual Studio and I was able to debug again with the Android Emulator and also publish for Android again.