Few days passed since the amazing event – Xamarin Experts Day and most of the questions I got were how to support the new presented upload format Android App Bundle – .aab using Azure DevOps and AppCenter since my topic was DevOps: Continuous delivery for Xamarin application, Azure DevOps and App Center, and in the demo I was using a Xamarin.Android build definition.
Note: The source code used for the build definition can be found on Github
And YES, more than expected, because many of us has seen this warning when creating a release on Play Store.

Further more, this awesome new publishing format will allow us to deliver smaller app, optimized for lots of devices and factors. If still not using it do not worry, Xamarin team already took care for all. You can read more in the Official site for Android developers or in the initial support for Xamarin.Android in Xamarin.Android 9.4 release notes and the Xamarin.Android 10.0 release notes
Android App Bundle with Azure DevOps
Prepare your app
Before looking into the processes, let’s take a look at the steps that need to be done, so your app will be prepared for deployment in this format.
Set AndroidPackageFormat property. It can be done by adding these lines of code in the .csproj file for the Android project.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AndroidPackageFormat>aab</AndroidPackageFormat>
</PropertyGroup>
Edit your build definition
With all this set up navigate to Azure DevOps and edit the Android build definition. The definition that builds the app should look something like this:

For now just disable the current Xamarin.Android task that builds the Android app with Xamarin. It is important not to delete it because soon this feature will be available directly in this task. But let’s take a look at the alternative for now.
Search for MsBuild task, that builds with MSBuild. After adding it, in the Project field set your Android .csproj file and set the MsBuild options like they are on your Xamarin.Android task.

Next thing to do is to add additional arguments for the build. Set these arguments in the MSBuild Arguments field:
-t:SignAndroidPackage
-p:Configuration=Release
-p:AndroidKeyStore=True
-p:AndroidSigningKeyStore=$(KeyStoreName)
-p:AndroidSigningStorePass=$(KeyStorePass)
-p:AndroidSigningKeyAlias=$(KeyStoreAlias)
-p:AndroidSigningKeyPass=$(KeyPass)
When AndroidPackageFormat is set as shown above, the SignAndroidPackage will create the .aab file in the bin directory, respectively in the chosen build configuration folder – the Release folder.
In the AndroidSigningKeyStore set the path where you store your .keystore file, if downloading from Secure Files – Library, check the target path folder inserted in the Download Secure File task.
After setting all these your YAML should look something like this:
steps:
- task: MSBuild@1
displayName: 'Build XamExpertsDay App'
inputs:
solution: XamExpertsDay.Android/XamExpertsDay.Android.csproj
msbuildArchitecture: x64
msbuildArguments: '-t:SignAndroidPackage -p:Configuration=Release -p:AndroidKeyStore=True -p:AndroidSigningKeyStore=$(KeyStoreName) -p:AndroidSigningStorePass=$(KeyStorePass) -p:AndroidSigningKeyAlias=$(KeyStoreAlias) -p:AndroidSigningKeyPass=$(KeyPass)'
Running this task will sign the app, so the Android Signing task will no longer be needed. Disable that task, or just simply remove it.
Few more additional steps
The MSBuild will create the .aab file in the bin folder within the Android Project folder. If the folder or file path you want to publish is Artifact staging directory or Binary directory and you want to continue using them in the artifact for publishing, add the Copy files task in between and move the .aab file there. For source folder set the path to .aab file and for target folder the publishing path.

After filling in this the YAML for Copy files task should look something like this:
steps:
- task: CopyFiles@2
displayName: 'Copy .aab to Binaries directory'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/XamExpertsDay.Android/bin/$(BuildConfiguration)/com.xamexpertsday.devopsdemo-Signed.aab'
TargetFolder: '$(build.binariesdirectory)/$(BuildConfiguration)'
With setting all these the build definition should look like this:

Next redeploy the app, and everything will be ready for publishing.
Once we have the .aab file the build artifacts we will probably need to deploy it on the Play Store. To see how to do that visit this link: Release Android App Bundle for Xamarin.Android apps using Azure DevOps
Android App Bundle with App Center
For App Center just use the simple switch, that can be found by editing the already existing Android Build Definition.

Save & Build. Done 🙂