Xamarin: How .NET MAUI will change the life of Xamarin.Forms development

.NET 6 and .NET MAUI is on the sill, but how will it affect the development of Xamarin applications?

For today, I have brought you a video by James Montemagno, a Xamarin developer working at Microsoft.

Follow James on the following platforms:

? https://montemagno.com
? https://mergeconflict.fm, https://blunders.fm, https://nintendodispatch.com
? https://twitter.com/jamesmontemagno
? https://youtube.com/jamesmontemagno

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Xamarin.Android : Google Play app target level error solution

If you are uploading an application to the Google Play, and it gives the following error:

Your app currently targets API level 28 and must target at least API  level 29 to ensure it is built on the latest APIs optimized for security  and performance. Change your app's target API level to at least 29 

You have to change the target framework and the target android version in your androidmanifest.xml or in the UI editor of the manifest. To change it, set the Target Framework in the properties tab of your android application

Changing target framework

Then Navigate to Android Manifest option, and set target android version

Setting Target Android version

If you are re archive your application, it will upload successfully.

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Xamarin.Android: Missing aapt.exe

When trying to deploy an application to simulator or device, Visual Studio gives the following error:

Cannot find `aapt.exe`. Please install the Android SDK Build-Tools package with the `C:\Program Files (x86)\Android\android-sdk\tools\android.bat` program.

To solve this problem you sould go to Visual Studio’s Tools then Android and select SDK Manager option.

Navigate to this option

It will give an error dialog, that the SDK tool files are corrupted. Click repair.

Click on Repair

The mentioned batch command in the error message is deprecated by the way.

Microsoft Windows [Version 10.0.19042.804]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\Users\banditoth>cd C:\Program Files (x86)\Android\android-sdk\tools\

C:\Program Files (x86)\Android\android-sdk\tools>android.bat
**************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat
**************************************************************************

Invalid or unsupported command ""

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk

C:\Program Files (x86)\Android\android-sdk\tools>

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Xamarin.Forms: Bindable Property snippet for Visual Studio

Use bprop tab tab to generate commands in ViewModels with this snippet

The result of the snippet

Save the snippet file as {name}.snippet in Visual Studio’s folder: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC#\Snippets\1033\Visual C#

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>Bindable Property</Title>
			<Shortcut>bprop</Shortcut>
			<Description>Xamarin BindableProperty declaration code snippet</Description>
			<Author>banditoth.hu</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>PropertyName</ID>
					<ToolTip>The property's name</ToolTip>
					<Default>Foo</Default>
				</Literal>
				<Literal>
					<ID>Type</ID>
					<ToolTip>The type of the property</ToolTip>
					<Default>object</Default>
				</Literal>
				<Literal>
					<ID>DefaultValue</ID>
					<ToolTip>The default value of the property</ToolTip>
					<Default>null</Default>
				</Literal>
				<Literal>
					<ID>BindingMode</ID>
					<ToolTip>The binding mode of the property</ToolTip>
					<Default>TwoWay</Default>
				</Literal>
				<Literal>
					<ID>PropertyChangedHandler</ID>
					<ToolTip>The property changed handler method</ToolTip>
					<Default>null</Default>
				</Literal>
				<Literal>
					<ID>PropertyChangingHandler</ID>
					<ToolTip>The property changing handler method</ToolTip>
					<Default>null</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp">
				<![CDATA[
        public static readonly BindableProperty $PropertyName$Property = BindableProperty.Create(
                                        propertyName: nameof($PropertyName$),
                                        returnType: typeof($Type$),
                                        declaringType: typeof(View),
                                        defaultValue: $DefaultValue$,
                                        defaultBindingMode: BindingMode.$BindingMode$,
                                        propertyChanged: $PropertyChangedHandler$,
					propertyChanging: $PropertyChangingHandler$);

        public $Type$ $PropertyName$
        {
            get { return ($Type$)GetValue($PropertyName$Property); }
            set { SetValue($PropertyName$Property, value); }
        }
		$end$]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.