Introduction

NET Multi-platform App UI (.NET MAUI) lets you build native apps using a .NET cross-platform UI toolkit that targets the mobile and desktop form factors on Android, iOS, macOS, Windows, and Tizen.

.NET MAUI is a cross-platform framework for creating native mobile and desktop apps with C# and XAML.

Using .NET MAUI, you can develop apps that can run on Android, iOS, macOS, and Windows from a single shared codebase.

NET MAUI is for developers who want to:

Please note that .NET MAUI apps can be written for the following platforms:

Earlier .NET MAUI was only supported with Visual Studio 2022 preview version. But from version 17.3.2 onwards, we can create .NET MAUI applications from Visual Studio 2022 itself.

In this post, we will see all the steps to create a native Android application using .NET MAU and Visual Studio 2022.

You must install any of the Visual Studio 2022 versions on your machine.

I am using Visual Studio 2022 Professional. As I told you earlier, please upgrade your Visual Studio version to 17.3.2 or higher.

Either install Visual Studio, or change your installation, and install the .NET Multi-platform App UI development workload with its default optional installation options:

After installing the .NET MAUI workload, we can start Visual Studio and choose the MAUI template. Currently, there are three types of .NET MAUI templates available.

We can choose the .NET MAUI App template.

After a few minutes, the new project will be created successfully.

We are focusing on creating an Android application with .NET MAUI.

Accelerating Android emulators on Windows

The following virtualization technologies are available for accelerating the Android emulator:

You can refer to Microsoft’s official documentation for more details about hardware acceleration.

We can use Android Device Manager to create and configure Android Virtual Devices (AVDs) that emulate physical Android devices.

To use the Android Device Manager, we need the following items.

We can choose Android Device Manager menu and continue.

Click New button to create a new Android Virtual Device.

Choose the required OS version and click the Create button.

We can add new properties as well if needed.

We must accept the Android SDK Preview License Agreement.

It will take some time to download and install the Virtual Device.

After installing the Virtual Device, we can click the Start button to start the emulator.

It will take a few minutes to start the emulator.

By default, Windows Machine mode is selected to run the application. We can choose Android emulator and run.

First time it will take more time to run the application in emulator. If you have Hyper-V installed on your machine, performance will be much better.

If you change any code inside the application, next time onwards the application will run extremely fast.

Publish.NET MAUI application for Android

When distributing our .NET MAUI application for Android, we generate an apk (Android Package) or an aab (Android App Bundle) file. The apk is used for installing our app to an Android device, and the aab is used to publish our app to an Android store.

Please note that we must change the Debug mode to Release mode before running the application.

After running the application in Release mode, we can see that the files below are created inside the Release folder of the application.

We can copy the apk file to any Android device and install it. Our application is ready on Android device, and we can run it.

Conclusion

In this post, we have seen the steps to install .NET MAUI workload in Visual Studio 2022 (version 17.3.2 or higher) and create a MAUI application. We have also created an Android Virtual Device and run the application in Android emulator. Please note that this is the very first step to create a mobile app with .NET MAUI. Microsoft is also giving elaborate documentation for MAUI. I also referred to their documentation to prepare this post. This is the first article in my .NET MAUI series. I will create more informative and useful articles in forthcoming days. Please give your valuable feedback and comments about .NET MAUI.