Getting Started with .NET Multi-platform App UI (MAUI) for Android
Karthik Krishna Baiju🔥🚀
Posted on June 12, 2021
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
3. Current state
Currently .NET MAUI is in Preview 4. Check out the official release 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
On successful installation of tool you can see the message following message on your terminal.
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
Tool will check for
- OpenJdk / AndroidSDK
- .NET 6 Preview SDK
- .NET MAUI Templates
Whenever tool prompt to "Attempt to fix?", type 'y' to continue. Screen shots show various stages of tool checking pre-requisites
After successful installation, tool shows following message. Press enter to exit.
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
Navigate to cloned path in your pc using command prompt
cd \maui-samples
To build Android project:
dotnet build HelloAndroid
To run Android project:
dotnet build HelloAndroid -t:Run
To launch .NET MAUI Project
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.
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:
dotnet new nugetconfig
dotnet nuget add source -n maui-preview https://aka.ms/maui-preview/index.json
In visual studio change target to android, hit F5 run in local device or Emulator
✌️ Your first MAUI App is up and running.
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.
Check sample application created in Github.
https://github.com/karthikeyen/maui-explorer
8. 🚀 What Is Next?
Please check out the official roadmap
Posted on June 12, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.