Getting Started with .NET Multi-platform App UI (MAUI) for Android
Tags: dotnet, maui, android, xamarinforms
Published: 2021-06-12 10:55:31

###1. What is .NET MAUI

.NET MAUI is the next generation of Xamarin.Forms, Microsoft's latest cross platform offering. .NET MAUI is the evolution of Xamain.Forms toolkit.

Highlights of .NET MAUI


* Cross Platform, Native UI
* Single Project, Single Codebase
* Deploy to multiple devices, mobile & desktop


###2. Evolution of .NET MAUI

.NET MAUI is the successor of Xamarin.Forms . Xamarin is a software company founded in 2011 by the engineers behind Mono, Xamarin.Android and Xamarin.IOS . In 2016 Xamarin has been acquired by Microsoft. 

Latest version of Xamarin.Forms, which is 5.0 released in 2021.
The next version of Xamarin.Forms is based on .NET 6. Its been announced that the next version of Xamarin.Forms is going to be .NET MAUI

![Evolution of .NET MAUI from Xamarin.Forms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6x4ilk7h55i9dahztm24.png)

###3. Current state

Currently .NET MAUI is in Preview 4. Check out the official [release](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-4/) announcement.

###4. Installation of .NET MAUI Check Tool

Run the following terminal command to install .NET MAUI Check Tool 

> dotnet tool install -g redth.net.maui.check

<small>*On successful installation of tool you can see the message following message on your terminal.*</small>

```
You can invoke the tool using the following command: maui-check
Tool 'redth.net.maui.check' (version '0.5.0') was successfully installed.
```

Once installation is done, run the following terminal command to install all pre-requisites required for .NET MAUI development

> maui-check

<small>Tool will check for</small>

* OpenJdk / AndroidSDK
* .NET 6 Preview SDK
* .NET MAUI Templates


<small>Whenever tool prompt to "Attempt to fix?", type 'y' to continue. *Screen shots show various stages of tool checking pre-requisites*</small>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0n4curr51hcdwn3okb9x.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eutu52e3er2ithrpzsj2.png)

<small>After successful installation, tool shows following message. Press enter to exit. </small>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsnkbpyhf28oyno70mqd.png)

###5. Get started with official samples

Connect your Android device in your PC or Launch Android Emulator before start.

Clone official .net maui samples repository

[https://github.com/dotnet/maui-samples.git](https://github.com/dotnet/maui-samples.git)

<small>Navigate to cloned path in your pc using command prompt</small>

> cd <path>\maui-samples

<small>To build Android project:</small>

> dotnet build HelloAndroid

<small>To run Android project:</small>

> dotnet build HelloAndroid -t:Run

<small>To launch .NET MAUI Project</small>

> dotnet build HelloMaui -t:Run -f net6.0-android

###6. Get started with Visual Studio 2019 Preview

Make sure you have latest preview installed on your PC.

![Visual studio version used for .NET MAUI Preview 4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rizyjav3vm039fckmusa.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/avnoy4ogs1wwbfo2tay0.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1imbhuqdh4j3o66j8w2i.png)

Before running the code, do nuget package addition in visual studio. Create a nuget.config file to the root of your project and add the following feed(s) with these commands:

> <small>dotnet new nugetconfig</small>
> <small>dotnet nuget add source -n maui-preview https://aka.ms/maui-preview/index.json</small>

In visual studio change target to android, hit F5 run in local device or Emulator

![Visual studio emulator selection for .NET MAUI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hycyk7ansj0jgxezm863.png)

✌️ Your first MAUI App is up and running.

![Running .NET MAUI Android Application](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vukufxar8xc93t4ym7uk.png)

###7. Battery Charge Indicator Sample Application for Android

I have created a MAUI application which shows the current battery charge percentage and source of power in an android device.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uh5koy2vgdb62bnft2ao.png)

Check sample application created in Github.

[https://github.com/karthikeyen/maui-explorer] (https://github.com/karthikeyen/maui-explorer)


###8. 🚀 What Is Next?

Please check out the official [roadmap](https://github.com/dotnet/maui/wiki/Roadmap)